Submission #331034

# Submission time Handle Problem Language Result Execution time Memory
331034 2020-11-27T05:06:31 Z CodeTiger927 Remittance (JOI19_remittance) C++14
0 / 100
1 ms 364 KB
using namespace std;

#include <iostream>

#define MAXN 100005

int N;
long long arrA[MAXN],arrB[MAXN],pref[MAXN];

int main() {
	cin >> N;

	int record = -1;
	for(int i = 0;i < N;++i) {
		cin >> arrA[i] >> arrB[i];
		pref[i] = arrA[i] - arrB[i];
		if(i > 0) pref[i] += pref[i - 1];
		if(record == -1 || pref[record] < pref[i]) {
			record = i;
		}
	}
	int curSum = 0;
	for(int i = 0;i < N;++i) {
		int cur = (record + i) % N;
		if(arrA[cur] - arrB[cur] + curSum < 0 || (arrA[cur] - arrB[cur] + curSum) % 2) {
			cout << "No" << endl;
			return 0;
		}
		curSum += arrA[cur] - arrB[cur];
		curSum = curSum / 2;
		curSum = max(curSum,0);
	}

	cout << "Yes" << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -