Guest User

Untitled

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