이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
int A[200005];
int B[200005];
int L[200005];
int ans[200005];
signed main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N, M;
cin >> N >> M;
int i, j;
for(i=0;i<N;i++) cin >> A[i] >> B[i];
for(i=0;i<N;i++) L[i] = B[i] - A[i];
for(i=0;i<M;i++) {
int c;
cin >> c;
for(j=0;j<N;j++) {
if(c<A[j]) {
ans[j] += A[j] - c;
A[j] = c, B[j] = c + L[j];
}
else if(c > B[j]) {
ans[j] += c - B[j];
B[j] = c, A[j] = c - L[j];
}
}
}
for(i=0;i<N;i++) cout << ans[i] << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |