제출 #963182

#제출 시각아이디문제언어결과실행 시간메모리
963182happy_node송금 (JOI19_remittance)C++17
100 / 100
349 ms36408 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int MX=1e6+5;
int N;
ll A[MX], B[MX];
 
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
 
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i]>>B[i];
 
	for(int k=0;k<51;k++) {
		for(int i=0;i<N;i++) {
			if(A[i]>B[i]) {
				ll nxt=min(A[i]/2,(A[i]-B[i]+1)/2);
				A[i]-=2*nxt;
				A[(i+1)%N]+=nxt;
			}
		}
	}
 
	bool ok=1;
	for(int i=0;i<N;i++) 
		ok&=A[i]==B[i];
 
	cout<<(ok?"Yes":"No")<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...