이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int bad() {
cout << "No\n";
return 0;
}
int main() {
int n;
cin >> n;
int a[n], b[n];
int peak = -1;
int peak_index = -1;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
if (a[i] > peak) {
peak = a[i];
peak_index = i;
}
}
rotate(a, a + peak_index, a + n);
rotate(b, b + peak_index, b + n);
for (int i = 0; i < n-1; i++) {
if (a[i] < b[i]) {
return bad();
}
int diff = a[i] - b[i];
if (diff % 2 == 1) {
return bad();
}
a[i] -= diff;
a[i+1] += diff/2;
}
if (a[n-1] == b[n-1]) {
cout << "Yes\n";
} else {
return bad();
}
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... |