This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long X[303030], Y[303030], Xi[303030], Yi[303030], SY[303030];
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int n, m, a, b;
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> Xi[i] >> X[i];
}
cin >> m;
for(int i = 1; i <= m; i++) {
cin >> Yi[i] >> Y[i];
}
cin >> a >> b;
for(int i = 1; i <= m; i++) {
SY[i] = SY[i-1] + Y[i];
}
long long ans = 0;
for(int i = 1; i <= n; i++) {
int l, r;
r = upper_bound(Yi+1, Yi+m+1, Xi[i]+b)-Yi-1;
l = lower_bound(Yi+1, Yi+m+1, Xi[i]+a)-Yi-1;
ans += X[i] * (SY[r]-SY[l]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |