이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int, lld> pil;
int N, M;
lld presum[300005], Xi[300005], X[300005], Yi[300005], Y[300005];
lld rst, a, b;
void input() {
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;
}
void f() {
for(int i = 1; i <= M; i++) presum[i] = Y[i] + presum[i-1];
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
input();
f();
for(int i = 1; i <= N; i++) {
int tmp = presum[upper_bound(Yi+1, Yi+M+1, Xi[i] + b) - Yi - 1] - presum[lower_bound(Yi+1, Yi+M+1, Xi[i]+a) - Yi - 1];
rst += tmp*X[i];
}
cout << rst;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |