Submission #904931

# Submission time Handle Problem Language Result Execution time Memory
904931 2024-01-12T11:33:30 Z Romicro Remittance (JOI19_remittance) C++17
0 / 100
1 ms 500 KB
#include <iostream>

#define endl '\n'

using namespace std;

const int MAXN = 1e5+100;

int n;
int cnt;

int a[MAXN], b[MAXN];

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

	cin >> n;

	for(int i=0; i<n; i++) cin >> a[i] >> b[i];

	int p=0;
	int mn = 1e9;
	for(int i=0; i<n;i++){
		if(a[i] - b[i] < mn){
			mn = a[i] - b[i];
			p = i;
		}
	}


	while(cnt < n){
		if(a[p] <= b[p]){
			cnt++;
			p++;
			continue;
		}

		int tmp = (a[p] - b[p])/2;
		if(tmp) cnt = 0;
		a[p] -= tmp*2;
		p = (p+1)%n;
		a[p] += tmp;
	}

	bool flg = true;
	for(int i=0; i<n; i++)
		if(a[i] != b[i]) flg = false;

	if(flg) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -