이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
const int MXN = 1000005;
int a[MXN], b[MXN];
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	bool ok = true, c = false;
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> a[i] >> b[i];
		if (b[i] > 0) c = true;
	}
	
	if (!c) {
		for (int i=1; i<=n; i++) {
			if (a[i] > 0) {
				cout << "No" << endl;
				exit(0);
			}
		}
		cout << "Yes" << endl;
		exit(0);
	}
	
	int cr = 0;
	for (int i=1; i<=30*n; i++) {
		
		cr++;
		if (cr == n + 1) cr = 1;
		if (a[cr] > b[cr]) {
			int diff = (a[cr] - b[cr]);
			int spl = (diff + 1) / 2;
			a[cr] -= spl * 2;
			if (cr < n) a[(cr+1)] += spl;
			else a[1] += spl;
		}
		
	}
	
	
	for (int i=1; i<=n; i++) {
		if (a[i] != b[i]) ok = false;
		if (b[i] > 0) c = true;
	}
	
	if (c && ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |