Saleh127

CF 1324D

Sep 3rd, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. ll a[200005],c[200005];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. ll e,f,i,j,k,l;
  13. cin>>e;
  14. for(i=0; i<e; i++)
  15. {
  16. cin>>a[i];
  17. }
  18. for(i=0; i<e; i++)
  19. {
  20. cin>>c[i];
  21. }
  22. vector < ll > d(e);
  23. for( i = 0 ; i < e ; i++)
  24. {
  25. d[i] = a[i] - c[i];
  26. }
  27.  
  28. sort(d.begin(), d.end());
  29. vector < ll > ::iterator it;
  30.  
  31. ll ans = 0;
  32. for(i = 0 ; i < e ; i++)
  33. {
  34. if(d[i]<= 0) continue;
  35. it = lower_bound(d.begin(), d.end(), -d[i]+1);
  36. int f = it-d.begin();
  37. ans += i-f;
  38. }
  39. cout << ans<<endl;
  40. return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment