Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- #endif
- int n;
- cin >> n;
- vector<int> A(n), B(n);
- for (auto &it : A) cin >> it;
- for (auto &it : B) cin >> it;
- vector<int> C(n);
- for(int i=0;i<n;i++)
- {
- C[i] = A[i]-B[i];
- }
- long long ans=0;
- sort(C.begin(),C.end());
- for(int i=0;i<n;i++)
- {
- if(C[i] <=0) continue;
- int y =lower_bound(C.begin(), C.end(), (1-C[i]))-C.begin();
- ans+=i-y;
- }
- cout << ans << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment