Guest User

Untitled

a guest
Mar 18th, 2020
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. #ifdef _DEBUG
  6. freopen("input.txt", "r", stdin);
  7. // freopen("output.txt", "w", stdout);
  8. #endif
  9.  
  10. int n;
  11. cin >> n;
  12. vector<int> A(n), B(n);
  13. for (auto &it : A) cin >> it;
  14. for (auto &it : B) cin >> it;
  15. vector<int> C(n);
  16. for(int i=0;i<n;i++)
  17. {
  18. C[i] = A[i]-B[i];
  19. }
  20. long long ans=0;
  21. sort(C.begin(),C.end());
  22. for(int i=0;i<n;i++)
  23. {
  24. if(C[i] <=0) continue;
  25. int y =lower_bound(C.begin(), C.end(), (1-C[i]))-C.begin();
  26. ans+=i-y;
  27. }
  28. cout << ans << endl;
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment