fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define kyd "light."
  5. #define int long long
  6. #define fi first
  7. #define se second
  8. #define pb push_back
  9. #define vi vector<int>
  10. #define ii pair<int, int>
  11. #define vii vector<ii>
  12. #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
  13. #define FORD(i, b, a) for(int i = (b), _a = (a); i >= _a; i--)
  14.  
  15. template<typename T> bool maximize(T &res, const T &val){ if(res < val){ res = val; return 1; } return 0; }
  16. template<typename T> bool minimize(T &res, const T &val){ if(res > val){ res = val; return 1; } return 0; }
  17.  
  18. const int MOD = 1e9+7;
  19.  
  20. int add(int a, int b){ if(a > MOD - b) return a - MOD + b; return a + b; }
  21. int mul(int a, int b){ return ((a % MOD) * (b % MOD)) % MOD; }
  22. int sub(int a, int b){ if(a < b) return a - b + MOD; return a - b; }
  23.  
  24. const int N = 1e5+5;
  25. int n, m;
  26. int b;
  27. int d;
  28. int a[N];
  29. vi s, t;
  30.  
  31. signed main(){
  32. ios_base::sync_with_stdio(0);
  33. cin.tie(0);
  34.  
  35. freopen(kyd"inp","r",stdin);
  36. freopen(kyd"out","w",stdout);
  37.  
  38. cin >> n >> m;
  39. FOR(i,1,n)
  40. cin >> a[i];
  41. FOR(i,1,n){
  42. cin >> b;
  43. s.pb(max(1ll, a[i]-b));
  44. t.pb(a[i]+b);
  45. }
  46. sort(s.begin(), s.end());
  47. sort(t.begin(), t.end());
  48.  
  49. FOR(i,1,m){
  50. cin >> d;
  51. cout << (upper_bound(s.begin(), s.end(), d) - s.begin()) - (lower_bound(t.begin(), t.end(), d) - t.begin()) << " ";
  52. }
  53.  
  54. return 0;
  55. }
  56.  
  57.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty