Submission #502849

# Submission time Handle Problem Language Result Execution time Memory
502849 2022-01-06T16:10:21 Z amunduzbaev Remittance (JOI19_remittance) C++14
0 / 100
1000 ms 204 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
#define int long long

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);

	int n; cin>>n;
	vector<int> a(n), b(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	
	bool is = 1;
	while(is){
		is = 0;
		for(int i=0;i<n;i++){
			if(a[i] <= b[i]) continue;
			int x = (a[i] - b[i]) / 2;
			a[(i + 1) % n] += x;
			a[i] -= 2 * x;
			is = 1;
		}
	}
	
	for(int i=0;i<n;i++){
		if(a[i] != b[i]){
			cout<<"No\n";
			return 0;
		}
	}
	
	cout<<"Yes\n";
}

# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -