Submission #685347

# Submission time Handle Problem Language Result Execution time Memory
685347 2023-01-24T06:05:50 Z flappybird Remittance (JOI19_remittance) C++17
15 / 100
1 ms 352 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 1020200
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
ll A[MAX];
ll B[MAX];
ll d[MAX];
ll X[MAX];
int N;
bool chk(ll x0) {
	X[N] = x0;
	int i;
	for (i = N - 1; i >= 0; i--) {
		X[i] = 2 * X[i + 1] + d[i + 1];
		if (X[i] < 0) return false;
		if (X[i] > 1e18) return false;
	}
	for (i = 0; i < N; i++) if (X[i] < 0) return false;
	return X[0] == X[N];
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> N;
	ll i;
	for (i = 0; i < N; i++) cin >> A[i] >> B[i], d[i] = B[i] - A[i];
	d[N] = d[0];
	ll sum = 0;
	for (i = 1; i <= min(60, N); i++) sum -= d[N - i + 1] >> i;
	int c = 0;
	for (i = sum - 50; i <= sum + 50; i++) {
		if (chk(i)) {
			c = 1;
			break;
		}
	}
	if (!c) {
		cout << "No" << ln;
		return 0;
	}
	while (1) {
		int c = 0;
		for (i = 0; i < N; i++) {
			if (X[i] && A[i] > 1) {
				c = 1;
				ll x = min(X[i], A[i] / 2);
				X[i] -= x;
				A[(i + 1) % N] += x;
				A[i] -= x * 2;
			}
		}
		if (!c) break;
	}
	int no = 0;
	for (i = 0; i < N; i++) if (X[i]) no = 1;
	if (!no) cout << "Yes" << ln;
	else cout << "No" << ln;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 0 ms 352 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 0 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 0 ms 352 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 0 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 352 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Incorrect 0 ms 340 KB Output isn't correct
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 0 ms 352 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 0 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 352 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Incorrect 0 ms 340 KB Output isn't correct
37 Halted 0 ms 0 KB -