답안 #231343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231343 2020-05-13T11:31:53 Z syy 송금 (JOI19_remittance) C++17
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, a[1000005], b[1000005], arr[1000005], cur, x;

int main() {
	fastio; cin >> n;
	FOR(i, 0, n-1) {
		cin >> a[i] >> b[i];
		arr[i] = a[i] - b[i];
		if (cur == 0 and arr[i] > 1) {
			cur = arr[i];
			x = i;
		}
	}
	while (cur > 0) {
		while (cur > 1) {
			arr[x] = cur % 2;
			x = (x+1)%n;
			cur /= 2;
			if (arr[x] > 0) cur += arr[x];
			else if (arr[x] < 0) {
				ll t = cur + arr[x];
				if (t >= 0) {
					arr[x] = 0;
					cur = t;
				} else {
					arr[x] = t;
					cur = 0;
				}
			}
		}
		FOR(i, 1, n-1) if (arr[i] > 1) {
			cur = arr[i]; x = i;
			break;
		}
	}
	bool ok = true;
	FOR(i, 0, n-1) if (arr[i] != 0) ok = false;
	cout << (ok ? "Yes" : "No");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Incorrect 5 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Incorrect 5 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Incorrect 5 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -