#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
vector<int> A(N), B(N);
for (int i = 0; i < N; ++i) {
cin >> A[i] >> B[i];
}
long double fdelta1 = A[0] - B[0];
long double pow2 = 1 / 4.;
for (int i = N - 1; i > 0; --i, pow2 /= 2.)
fdelta1 += (A[i] - B[i]) * pow2;
vector<int> delta(N);
delta[0] = roundl(fdelta1);
for (int i = 1; i < N; ++i) {
delta[i] = (A[i] - B[i] + delta[i - 1]) / 2;
}
for (int i = 0; i < N; ++i) {
if (delta[i] < 0 or
A[i] - 2 * delta[i] + delta[i ? i - 1 : N - 1] != B[i]) {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |