#include <iostream>
#include <fstream>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#define MAX_N 1000005
#define f first
#define s second
using namespace std;
typedef pair<int, int> ii;
int A[MAX_N], B[MAX_N];
int N;
void solve() {
cin >> N;
for (int i = 0; i < N; i ++) {
cin >> A[i] >> B[i];
}
int carry;
for (int ii = 0; ii < 100; ii ++) {
for (int i = 0; i < N; i ++) {
if (A[i] > B[i]) {
carry = ((A[i] - B[i]) / 2);
A[i] -= ((A[i] - B[i]) / 2) * 2;
A[(i + 1) % N] += carry;
}
}
}
bool flag = true;
for (int i = 0; i < N; i ++) {
flag = (flag && (A[i] == B[i]));
}
if (flag)
cout << ("Yes") << endl;
else {
cout << "No" << endl;
}
return;
}
int main() {
int T;
T = 1;
for (int i = 0; i < T; i ++) {
solve();
}
return (0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |