답안 #514931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
514931 2022-01-18T20:16:47 Z Abrar_Al_Samit 송금 (JOI19_remittance) C++17
0 / 100
0 ms 204 KB
#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];
	}
	int lastRem = -1;
	int now = 0;
	int v = 0;
	do {
		long long can = max(0LL, a[v]-b[v]);
		if(can&1) {
			if(can==a[v]) --can;
			else ++can;
		}
		if(can) {
			lastRem = now;
		}
		++now;
		a[v] -= can;
		v = (v+1)%n;
		a[v] += can/2;
	} while(now-lastRem<n);

	bool ok = 1;
	for(int i=0; i<n; ++i) {
		ok &= a[i]==b[i];
	}
	cout << (ok?"Yes\n":"No\n");

	//O(Nlog(max A[i]))

	// 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -