답안 #211768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211768 2020-03-21T08:10:06 Z tselmegkh 송금 (JOI19_remittance) C++14
100 / 100
490 ms 28792 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e6 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool solve(int idx, vi &m, vi &l){
	int cnt = 0, n = m.size();
	for(int i = idx;; i++){
		if(i >= n)i -= n;
		if(i == idx){
			cnt++;
			if(cnt == 50)break;
		}
		if(m[i] > l[i]){
			int x = (m[i] - l[i]) / 2;
			m[(i + 1) % n] += x;
			m[i] -= (2 * x);
			if((m[i] - l[i]) % 2 == 1){
				if(m[i] >= 2){
					m[i] -= 2;
					m[(i + 1) % n] += 1;
				}
			}
		}
	}
	for(int i = 0; i < n; i++){
		if(m[i] != l[i])return 0;
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vi m(n), l(n);
	for(int i = 0; i < n; i++){
		cin >> m[i] >> l[i];
	}
	if(solve(0, m, l)){
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 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 304 KB Output is correct
8 Correct 5 ms 432 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 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 304 KB Output is correct
8 Correct 5 ms 432 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 4 ms 384 KB Output is correct
37 Correct 4 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 4 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 4 ms 384 KB Output is correct
47 Correct 4 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 5 ms 384 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 4 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 4 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 4 ms 384 KB Output is correct
62 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 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 304 KB Output is correct
8 Correct 5 ms 432 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 4 ms 384 KB Output is correct
37 Correct 4 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 4 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 4 ms 384 KB Output is correct
47 Correct 4 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 5 ms 384 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 4 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 4 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 4 ms 384 KB Output is correct
62 Correct 5 ms 512 KB Output is correct
63 Correct 393 ms 27512 KB Output is correct
64 Correct 242 ms 12152 KB Output is correct
65 Correct 397 ms 27188 KB Output is correct
66 Correct 233 ms 12152 KB Output is correct
67 Correct 248 ms 13560 KB Output is correct
68 Correct 258 ms 15864 KB Output is correct
69 Correct 401 ms 27640 KB Output is correct
70 Correct 225 ms 12152 KB Output is correct
71 Correct 244 ms 13432 KB Output is correct
72 Correct 281 ms 16296 KB Output is correct
73 Correct 399 ms 27512 KB Output is correct
74 Correct 249 ms 12156 KB Output is correct
75 Correct 245 ms 13432 KB Output is correct
76 Correct 258 ms 15864 KB Output is correct
77 Correct 407 ms 27896 KB Output is correct
78 Correct 472 ms 19832 KB Output is correct
79 Correct 490 ms 19832 KB Output is correct
80 Correct 319 ms 19832 KB Output is correct
81 Correct 340 ms 19960 KB Output is correct
82 Correct 387 ms 12152 KB Output is correct
83 Correct 224 ms 12408 KB Output is correct
84 Correct 215 ms 12024 KB Output is correct
85 Correct 401 ms 28792 KB Output is correct
86 Correct 410 ms 28584 KB Output is correct
87 Correct 481 ms 20984 KB Output is correct
88 Correct 331 ms 20964 KB Output is correct