답안 #432076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432076 2021-06-17T20:17:11 Z OkMaybe 송금 (JOI19_remittance) C++14
100 / 100
909 ms 24804 KB
/*input
2
1 1
2 2
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
int main()
{
	clock_t pradzia = clock();
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	ll a[n], b[n];
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	while ((clock() - pradzia) * 10 <= 9 * CLOCKS_PER_SEC)
	{
		bool ok = true;
		for (int i = n - 1; i >= 0; i--)
		{
			if (a[i] < b[i])
			{
				ll c = min(a[(i - 1 + n) % n] / 2, b[i] - a[i]);
				a[i] += c;
				a[(i - 1 + n) % n] -= 2 * c;
				ok = false;
			}
		}
		for (int i = 0; i < n; i++)
		{
			if (a[i] > b[i])
			{
				ll c = min(a[i] / 2, (a[i] - b[i] + 1) / 2);
				a[i] -= c * 2;
				a[(i + 1) % n] += c;
				ok = false;
			}
		}
		if (ok)
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 901 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 901 ms 204 KB Output is correct
13 Correct 901 ms 292 KB Output is correct
14 Correct 901 ms 292 KB Output is correct
15 Correct 900 ms 292 KB Output is correct
16 Correct 901 ms 292 KB Output is correct
17 Correct 901 ms 296 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 901 ms 292 KB Output is correct
20 Correct 901 ms 296 KB Output is correct
21 Correct 901 ms 300 KB Output is correct
22 Correct 901 ms 292 KB Output is correct
23 Correct 901 ms 292 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 901 ms 292 KB Output is correct
26 Correct 901 ms 296 KB Output is correct
27 Correct 901 ms 292 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 901 ms 288 KB Output is correct
31 Correct 901 ms 296 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 901 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 901 ms 204 KB Output is correct
13 Correct 901 ms 292 KB Output is correct
14 Correct 901 ms 292 KB Output is correct
15 Correct 900 ms 292 KB Output is correct
16 Correct 901 ms 292 KB Output is correct
17 Correct 901 ms 296 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 901 ms 292 KB Output is correct
20 Correct 901 ms 296 KB Output is correct
21 Correct 901 ms 300 KB Output is correct
22 Correct 901 ms 292 KB Output is correct
23 Correct 901 ms 292 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 901 ms 292 KB Output is correct
26 Correct 901 ms 296 KB Output is correct
27 Correct 901 ms 292 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 901 ms 288 KB Output is correct
31 Correct 901 ms 296 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 901 ms 292 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 304 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 312 KB Output is correct
42 Correct 901 ms 292 KB Output is correct
43 Correct 901 ms 296 KB Output is correct
44 Correct 901 ms 292 KB Output is correct
45 Correct 901 ms 296 KB Output is correct
46 Correct 901 ms 288 KB Output is correct
47 Correct 901 ms 292 KB Output is correct
48 Correct 901 ms 288 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 901 ms 292 KB Output is correct
51 Correct 901 ms 296 KB Output is correct
52 Correct 901 ms 288 KB Output is correct
53 Correct 901 ms 288 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 901 ms 288 KB Output is correct
56 Correct 901 ms 288 KB Output is correct
57 Correct 901 ms 292 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 288 KB Output is correct
60 Correct 901 ms 288 KB Output is correct
61 Correct 901 ms 300 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 901 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 901 ms 204 KB Output is correct
13 Correct 901 ms 292 KB Output is correct
14 Correct 901 ms 292 KB Output is correct
15 Correct 900 ms 292 KB Output is correct
16 Correct 901 ms 292 KB Output is correct
17 Correct 901 ms 296 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 901 ms 292 KB Output is correct
20 Correct 901 ms 296 KB Output is correct
21 Correct 901 ms 300 KB Output is correct
22 Correct 901 ms 292 KB Output is correct
23 Correct 901 ms 292 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 901 ms 292 KB Output is correct
26 Correct 901 ms 296 KB Output is correct
27 Correct 901 ms 292 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 901 ms 288 KB Output is correct
31 Correct 901 ms 296 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 901 ms 292 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 304 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 312 KB Output is correct
42 Correct 901 ms 292 KB Output is correct
43 Correct 901 ms 296 KB Output is correct
44 Correct 901 ms 292 KB Output is correct
45 Correct 901 ms 296 KB Output is correct
46 Correct 901 ms 288 KB Output is correct
47 Correct 901 ms 292 KB Output is correct
48 Correct 901 ms 288 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 901 ms 292 KB Output is correct
51 Correct 901 ms 296 KB Output is correct
52 Correct 901 ms 288 KB Output is correct
53 Correct 901 ms 288 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 901 ms 288 KB Output is correct
56 Correct 901 ms 288 KB Output is correct
57 Correct 901 ms 292 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 288 KB Output is correct
60 Correct 901 ms 288 KB Output is correct
61 Correct 901 ms 300 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
63 Correct 903 ms 16428 KB Output is correct
64 Correct 170 ms 19768 KB Output is correct
65 Correct 271 ms 16436 KB Output is correct
66 Correct 176 ms 19804 KB Output is correct
67 Correct 184 ms 21188 KB Output is correct
68 Correct 195 ms 23488 KB Output is correct
69 Correct 282 ms 16504 KB Output is correct
70 Correct 903 ms 19848 KB Output is correct
71 Correct 902 ms 21240 KB Output is correct
72 Correct 902 ms 23604 KB Output is correct
73 Correct 903 ms 16440 KB Output is correct
74 Correct 902 ms 19900 KB Output is correct
75 Correct 903 ms 21236 KB Output is correct
76 Correct 904 ms 23604 KB Output is correct
77 Correct 905 ms 16436 KB Output is correct
78 Correct 902 ms 24796 KB Output is correct
79 Correct 906 ms 24800 KB Output is correct
80 Correct 234 ms 24712 KB Output is correct
81 Correct 909 ms 24804 KB Output is correct
82 Correct 903 ms 19848 KB Output is correct
83 Correct 907 ms 19768 KB Output is correct
84 Correct 165 ms 19772 KB Output is correct
85 Correct 332 ms 16452 KB Output is correct
86 Correct 905 ms 16436 KB Output is correct
87 Correct 904 ms 24800 KB Output is correct
88 Correct 256 ms 24804 KB Output is correct