I used [problem:600B] to test those and used the same code but with change in input and output streams.↵
↵
<table>↵
<tbody>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> </td>↵
<td style="height: 23px;">Cin And Cout </td>↵
<td style="height: 23px;"> Scanf And Printf</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++ 5.1.0</td>↵
<td style="height: 23px;"> 358ms Submission:[submission:35214275]</td>↵
<td style="height: 23px;"> 155ms Submission:[submission:35214230]</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++11 5.1.0</td>↵
<td style="height: 23px;"> 343ms Submission:[submission:35214311]</td>↵
<td style="height: 23px;"> 156ms Submission:[submission:35214295]</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++14 6.4.0</td>↵
<td style="height: 23px;"> 187ms Submission:[submission:35214315]</td>↵
<td style="height: 23px;"> 186ms Submission:[submission:35214352]</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++17 7.2.0</td>↵
<td style="height: 23px;"> 187ms Submission:[submission:35214359]</td>↵
<td style="height: 23px;"> 187ms Submission:[submission:35214322]</td>↵
</tr>↵
</tbody>↵
</table>↵
↵
Looks like that scanf&printf is almost the same but cin&cout is slower under c++14.↵
↵
Don't use cin&cout under c++14 to avoid TLE.↵
↵
↵
↵
Scanf And Printf Code↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
int n,m,val;↵
vector<int> a;↵
int main() {↵
scanf("%d%d",&n,&m);↵
for(int i = 0;i < n;i++){↵
scanf("%d",&val);↵
a.push_back(val);↵
}↵
sort(a.begin(),a.end());↵
for(int i = 0;i < m;i++){↵
int b;↵
scanf("%d",&b);↵
printf("%d ",upper_bound(a.begin(),a.end(),b)-a.begin());↵
}↵
return 0;↵
}↵
~~~~~↵
↵
Cin And Cout Code↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
int n,m,val;↵
vector<int> a;↵
int main() {↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);↵
cin >> n >> m;↵
for(int i = 0;i < n;i++){↵
cin >> val;↵
a.push_back(val);↵
}↵
sort(a.begin(),a.end());↵
for(int i = 0;i < m;i++){↵
int b;↵
cin >> b;↵
cout << upper_bound(a.begin(),a.end(),b)-a.begin() << " ";↵
}↵
return 0;↵
}↵
~~~~~↵
↵
↵
↵
↵
<table>↵
<tbody>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> </td>↵
<td style="height: 23px;">Cin And Cout </td>↵
<td style="height: 23px;"> Scanf And Printf</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++ 5.1.0</td>↵
<td style="height: 23px;"> 358ms Submission:[submission:35214275]</td>↵
<td style="height: 23px;"> 155ms Submission:[submission:35214230]</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++11 5.1.0</td>↵
<td style="height: 23px;"> 343ms Submission:[submission:35214311]</td>↵
<td style="height: 23px;"> 156ms Submission:[submission:35214295]</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++14 6.4.0</td>↵
<td style="height: 23px;"> 187ms Submission:[submission:35214315]</td>↵
<td style="height: 23px;"> 186ms Submission:[submission:35214352]</td>↵
</tr>↵
<tr style="height: 23px;">↵
<td style="height: 23px;"> GNU C++17 7.2.0</td>↵
<td style="height: 23px;"> 187ms Submission:[submission:35214359]</td>↵
<td style="height: 23px;"> 187ms Submission:[submission:35214322]</td>↵
</tr>↵
</tbody>↵
</table>↵
↵
Looks like that scanf&printf is almost the same but cin&cout is slower under c++14.↵
↵
Don't use cin&cout under c++14 to avoid TLE.↵
↵
↵
↵
Scanf And Printf Code↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
int n,m,val;↵
vector<int> a;↵
int main() {↵
scanf("%d%d",&n,&m);↵
for(int i = 0;i < n;i++){↵
scanf("%d",&val);↵
a.push_back(val);↵
}↵
sort(a.begin(),a.end());↵
for(int i = 0;i < m;i++){↵
int b;↵
scanf("%d",&b);↵
printf("%d ",upper_bound(a.begin(),a.end(),b)-a.begin());↵
}↵
return 0;↵
}↵
~~~~~↵
↵
Cin And Cout Code↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
int n,m,val;↵
vector<int> a;↵
int main() {↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);↵
cin >> n >> m;↵
for(int i = 0;i < n;i++){↵
cin >> val;↵
a.push_back(val);↵
}↵
sort(a.begin(),a.end());↵
for(int i = 0;i < m;i++){↵
int b;↵
cin >> b;↵
cout << upper_bound(a.begin(),a.end(),b)-a.begin() << " ";↵
}↵
return 0;↵
}↵
~~~~~↵
↵
↵
↵