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