답안 #755530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755530 2023-06-10T08:35:47 Z jmyszka2007 송금 (JOI19_remittance) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int LIM = 1e6;
ll a[LIM + 10];
ll b[LIM + 10];
ll x[LIM + 10];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
		ans += (b[i] - a[i]) * (1ll << (i - 1));
	}
	if(ans % ((1ll << n) - 1)) {
		cout << "No\n";
	}
	else {
		bool czy = 1;
		ans /= ((1ll << n) - 1);
		x[n] = ans;
		for(int i = n - 1; i >= 1; i--) {
			if((a[i] + x[i + 1] - b[i]) & 1) {
				czy = 0;
				break;
			}
			else {
				x[i] = (a[i] + x[i + 1] - b[i]) / 2;
			}
		}
		if(czy) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -