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