#include<bits/stdc++.h>
using namespace std;
int main()
{
int a; cin >> a;
pair<int, int> arr[a + 50];
for(int i=0; i < a; i ++)
cin >> arr[i].first >> arr[i].second;
while(true)
{
bool yes = false;
for(int i=0; i < a; i ++)
{
if(arr[i].first < arr[i].second + 2) continue;
int t = (arr[i].first - arr[i].second) / 2;
arr[i].first -= t * 2;
if(i == a - 1) arr[0].first += t;
else arr[i + 1].first += t;
yes = true;
}
if(!yes) break;
}
bool yes1 = true, yes2 = true;
for(int i=0; i < a; i ++)
{
if(arr[i].first != arr[i].second) yes1 = false;
if(arr[i].first != arr[i].second + 1 || arr[i].first < 2) yes2 = false;
}
if(yes1 || yes2) cout << "Yes";
else cout << "No";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |