#include<bits/stdc++.h>
#define endl '\n'
typedef long long ll;
const int MAX_N = 1e6 + 10;
int n;
ll a[MAX_N], b[MAX_N];
void solve()
{
//std::cout << "Yes" << endl;
//exit(0);
std::cin >> n;
for (int i = 1; i <= n; i ++)
std::cin >> a[i] >> b[i];
while(true)
{
bool done = true;
for (int i = 1; i <= n; i ++)
{
int nxt = i + 1;
if (i == n)
nxt = 1;
ll left = a[i] - b[i];
if (left < 0)
left = 0;
left /= 2;
a[i] -= left * 2;
a[nxt] += left;
if (left != 0)
done = false;
}
if (done)
break;
}
bool fine = true;
for (int i = 1; i <= n; i ++)
if (a[i] != b[i])
fine = false;
if (fine)
std::cout << "Yes" << endl;
else
std::cout << "No" << endl;
}
void speed()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
}
int main()
{
solve();
return 0;
}
/**
2
0 2
4 0
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |