이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
void PlayGround() {
	int n;
	cin >> n;
	long long a[n], b[n];
	for(int i=0; i<n; ++i) {
		cin >> a[i] >> b[i];
	}
	long long have[n];
	for(int i=0; i<n; ++i) {
		have[i] = a[i];
	}
	int lastRem = -1;
	int now = 0;
	int v = 0;
	while(1) {
		long long can = max(0LL, have[v]-b[v]);
		if(can&1) {
			if(can==have[v]) --can;
			else ++can;
		}
		if(can) {
			lastRem = now;
		} else {
			if(now-lastRem==n) break;
		}
		++now;
		have[v] -= can;
		can /= 2;
		have[(v+1)%n] += can;
		v = (v+1)%n;
	}
	bool ok = 1;
	for(int i=0; i<n; ++i) {
		ok &= have[i]==b[i];
	}
	if(ok) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	//O(NlogN)
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	PlayGround();
	return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |