답안 #717990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
717990 2023-04-03T06:06:11 Z Radin_Zahedi2 송금 (JOI19_remittance) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)x.size()
#define endl '\n'


int n;
const int N = 1e6 + 5;
int d[N];

void input() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;

		d[i] = a - b;
	}
}

void solve() {
	for (int t = 0; t < 60; t++) {
		for (int i = 0; i < n - 1; i++) {
			if (d[i] > 0) {
				d[i + 1] += d[i] / 2;
				d[i] %= 2;
			}
		}

		if (d[n - 1] > 0) {
			d[0] += d[n - 1] / 2;
			d[n - 1] %= 2;
		}
	}

	for (int i = 0; i < n; i++) {
		if (d[i]) {
			cout << "No";
			return;
		}
	}

	cout << "Yes";
}

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


	input();

	solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Incorrect 0 ms 328 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Incorrect 0 ms 328 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Incorrect 0 ms 328 KB Output isn't correct
9 Halted 0 ms 0 KB -