이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Muallif: Azimjon Mehmonali o'g'li
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;
const int N = 100;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
pair<int, int> p{-1, -1};
for (int i = 1; i <= n; i++) {
p = max(p, make_pair(a[i] - b[i], i));
}
int t = 1000;
while (t--) {
for (int i = p.second; i < n; i++) {
if (a[i] < b[i]) continue;
int z = a[i] - b[i];
z /= 2;
a[i] -= 2 * z;
a[i + 1] += z;
}
int z = a[n] - b[n];
z /= 2;
a[n] -= 2 * z;
a[1] += z;
for (int i = 1; i < p.second; i++) {
if (a[i] < b[i]) continue;
int z = a[i] - b[i];
z /= 2;
a[i] -= 2 * z;
a[i + 1] += z;
}
}
if (a == b) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
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... |