fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int MaxN=2e5;
  4. const int MaxA=1e9;
  5. int A[MaxN]={};
  6. int main() {
  7. int N,Q,x;
  8. for(int n=0;n<N;n++){
  9. cin>>x;
  10. A[n]-=x;
  11. }
  12. sort(A,A+N);
  13. for(int q=0;q<Q;q++){
  14. cin>>x;
  15. cout<<upper_bound(A,A+N,-x)-A<<"\n";
  16. }
  17. }
Success #stdin #stdout 0.01s 5280KB
stdin
5 5
1 2 3 4 5
6
5
4
3
2
stdout
Standard output is empty