# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
545563 | 2022-04-04T21:24:46 Z | MilosMilutinovic | Bootfall (IZhO17_bootfall) | C++14 | 384 ms | 4484 KB |
#include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;} template<typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;} const int md=1e9+7; int n,a[505],dp[505*505],cc[505*505],ndp[505*505]; void chkadd(int&x,int y){x+=y; if(x>md) x-=md;} void chksub(int&x,int y){x-=y; if(x<0) x+=md;} int main(){ scanf("%d",&n); dp[0]=1; int s=0; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); for(int j=505*505-1;j>=a[i];j--) chkadd(dp[j],dp[j-a[i]]); s+=a[i]; } if((s&1)||!dp[s/2]){printf("0"); return 0;} for(int i=1;i<=n;i++){ for(int j=0;j<505*505;j++) ndp[j]=dp[j]; for(int j=0;j<505*505-a[i];j++) chksub(ndp[j+a[i]],ndp[j]); for(int j=0;j<505*505;j++){ int ns=s-a[i]+j; if(ns/2-j>=0&&ns%2==0&&ndp[ns/2-j]) cc[j]++; } } vector<int> ans; for(int i=0;i<505*505;i++) if(cc[i]==n) ans.pb(i); printf("%d\n",ans.size()); for(int i=0;i<ans.size();i++) printf("%d ",ans[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2260 KB | Output is correct |
2 | Correct | 6 ms | 2228 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 5 ms | 2260 KB | Output is correct |
5 | Correct | 10 ms | 2308 KB | Output is correct |
6 | Correct | 8 ms | 2224 KB | Output is correct |
7 | Correct | 8 ms | 2260 KB | Output is correct |
8 | Correct | 10 ms | 2260 KB | Output is correct |
9 | Correct | 9 ms | 2260 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2260 KB | Output is correct |
2 | Correct | 6 ms | 2228 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 5 ms | 2260 KB | Output is correct |
5 | Correct | 10 ms | 2308 KB | Output is correct |
6 | Correct | 8 ms | 2224 KB | Output is correct |
7 | Correct | 8 ms | 2260 KB | Output is correct |
8 | Correct | 10 ms | 2260 KB | Output is correct |
9 | Correct | 9 ms | 2260 KB | Output is correct |
10 | Correct | 22 ms | 2260 KB | Output is correct |
11 | Correct | 24 ms | 2212 KB | Output is correct |
12 | Correct | 23 ms | 2300 KB | Output is correct |
13 | Correct | 20 ms | 2204 KB | Output is correct |
14 | Correct | 22 ms | 2260 KB | Output is correct |
15 | Correct | 26 ms | 2292 KB | Output is correct |
16 | Correct | 25 ms | 2260 KB | Output is correct |
17 | Correct | 15 ms | 2260 KB | Output is correct |
18 | Correct | 18 ms | 2304 KB | Output is correct |
19 | Correct | 21 ms | 2308 KB | Output is correct |
20 | Correct | 22 ms | 2204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2260 KB | Output is correct |
2 | Correct | 6 ms | 2228 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 5 ms | 2260 KB | Output is correct |
5 | Correct | 10 ms | 2308 KB | Output is correct |
6 | Correct | 8 ms | 2224 KB | Output is correct |
7 | Correct | 8 ms | 2260 KB | Output is correct |
8 | Correct | 10 ms | 2260 KB | Output is correct |
9 | Correct | 9 ms | 2260 KB | Output is correct |
10 | Correct | 22 ms | 2260 KB | Output is correct |
11 | Correct | 24 ms | 2212 KB | Output is correct |
12 | Correct | 23 ms | 2300 KB | Output is correct |
13 | Correct | 20 ms | 2204 KB | Output is correct |
14 | Correct | 22 ms | 2260 KB | Output is correct |
15 | Correct | 26 ms | 2292 KB | Output is correct |
16 | Correct | 25 ms | 2260 KB | Output is correct |
17 | Correct | 15 ms | 2260 KB | Output is correct |
18 | Correct | 18 ms | 2304 KB | Output is correct |
19 | Correct | 21 ms | 2308 KB | Output is correct |
20 | Correct | 22 ms | 2204 KB | Output is correct |
21 | Correct | 46 ms | 2212 KB | Output is correct |
22 | Correct | 51 ms | 2304 KB | Output is correct |
23 | Correct | 42 ms | 2208 KB | Output is correct |
24 | Correct | 75 ms | 2324 KB | Output is correct |
25 | Correct | 67 ms | 2252 KB | Output is correct |
26 | Correct | 71 ms | 2336 KB | Output is correct |
27 | Correct | 69 ms | 2320 KB | Output is correct |
28 | Correct | 69 ms | 2252 KB | Output is correct |
29 | Correct | 72 ms | 2448 KB | Output is correct |
30 | Correct | 70 ms | 2316 KB | Output is correct |
31 | Correct | 68 ms | 2324 KB | Output is correct |
32 | Correct | 69 ms | 2260 KB | Output is correct |
33 | Correct | 70 ms | 2328 KB | Output is correct |
34 | Correct | 67 ms | 2324 KB | Output is correct |
35 | Correct | 66 ms | 2328 KB | Output is correct |
36 | Correct | 72 ms | 2316 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2260 KB | Output is correct |
2 | Correct | 6 ms | 2228 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 5 ms | 2260 KB | Output is correct |
5 | Correct | 10 ms | 2308 KB | Output is correct |
6 | Correct | 8 ms | 2224 KB | Output is correct |
7 | Correct | 8 ms | 2260 KB | Output is correct |
8 | Correct | 10 ms | 2260 KB | Output is correct |
9 | Correct | 9 ms | 2260 KB | Output is correct |
10 | Correct | 22 ms | 2260 KB | Output is correct |
11 | Correct | 24 ms | 2212 KB | Output is correct |
12 | Correct | 23 ms | 2300 KB | Output is correct |
13 | Correct | 20 ms | 2204 KB | Output is correct |
14 | Correct | 22 ms | 2260 KB | Output is correct |
15 | Correct | 26 ms | 2292 KB | Output is correct |
16 | Correct | 25 ms | 2260 KB | Output is correct |
17 | Correct | 15 ms | 2260 KB | Output is correct |
18 | Correct | 18 ms | 2304 KB | Output is correct |
19 | Correct | 21 ms | 2308 KB | Output is correct |
20 | Correct | 22 ms | 2204 KB | Output is correct |
21 | Correct | 46 ms | 2212 KB | Output is correct |
22 | Correct | 51 ms | 2304 KB | Output is correct |
23 | Correct | 42 ms | 2208 KB | Output is correct |
24 | Correct | 75 ms | 2324 KB | Output is correct |
25 | Correct | 67 ms | 2252 KB | Output is correct |
26 | Correct | 71 ms | 2336 KB | Output is correct |
27 | Correct | 69 ms | 2320 KB | Output is correct |
28 | Correct | 69 ms | 2252 KB | Output is correct |
29 | Correct | 72 ms | 2448 KB | Output is correct |
30 | Correct | 70 ms | 2316 KB | Output is correct |
31 | Correct | 68 ms | 2324 KB | Output is correct |
32 | Correct | 69 ms | 2260 KB | Output is correct |
33 | Correct | 70 ms | 2328 KB | Output is correct |
34 | Correct | 67 ms | 2324 KB | Output is correct |
35 | Correct | 66 ms | 2328 KB | Output is correct |
36 | Correct | 72 ms | 2316 KB | Output is correct |
37 | Correct | 133 ms | 2488 KB | Output is correct |
38 | Correct | 134 ms | 2444 KB | Output is correct |
39 | Correct | 189 ms | 2528 KB | Output is correct |
40 | Correct | 188 ms | 2576 KB | Output is correct |
41 | Correct | 183 ms | 2568 KB | Output is correct |
42 | Correct | 181 ms | 2528 KB | Output is correct |
43 | Correct | 169 ms | 2836 KB | Output is correct |
44 | Correct | 172 ms | 2896 KB | Output is correct |
45 | Correct | 168 ms | 2840 KB | Output is correct |
46 | Correct | 187 ms | 2380 KB | Output is correct |
47 | Correct | 183 ms | 2572 KB | Output is correct |
48 | Correct | 178 ms | 2764 KB | Output is correct |
49 | Correct | 178 ms | 2572 KB | Output is correct |
50 | Correct | 178 ms | 2552 KB | Output is correct |
51 | Correct | 64 ms | 1236 KB | Output is correct |
52 | Correct | 189 ms | 2956 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2260 KB | Output is correct |
2 | Correct | 6 ms | 2228 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 5 ms | 2260 KB | Output is correct |
5 | Correct | 10 ms | 2308 KB | Output is correct |
6 | Correct | 8 ms | 2224 KB | Output is correct |
7 | Correct | 8 ms | 2260 KB | Output is correct |
8 | Correct | 10 ms | 2260 KB | Output is correct |
9 | Correct | 9 ms | 2260 KB | Output is correct |
10 | Correct | 22 ms | 2260 KB | Output is correct |
11 | Correct | 24 ms | 2212 KB | Output is correct |
12 | Correct | 23 ms | 2300 KB | Output is correct |
13 | Correct | 20 ms | 2204 KB | Output is correct |
14 | Correct | 22 ms | 2260 KB | Output is correct |
15 | Correct | 26 ms | 2292 KB | Output is correct |
16 | Correct | 25 ms | 2260 KB | Output is correct |
17 | Correct | 15 ms | 2260 KB | Output is correct |
18 | Correct | 18 ms | 2304 KB | Output is correct |
19 | Correct | 21 ms | 2308 KB | Output is correct |
20 | Correct | 22 ms | 2204 KB | Output is correct |
21 | Correct | 46 ms | 2212 KB | Output is correct |
22 | Correct | 51 ms | 2304 KB | Output is correct |
23 | Correct | 42 ms | 2208 KB | Output is correct |
24 | Correct | 75 ms | 2324 KB | Output is correct |
25 | Correct | 67 ms | 2252 KB | Output is correct |
26 | Correct | 71 ms | 2336 KB | Output is correct |
27 | Correct | 69 ms | 2320 KB | Output is correct |
28 | Correct | 69 ms | 2252 KB | Output is correct |
29 | Correct | 72 ms | 2448 KB | Output is correct |
30 | Correct | 70 ms | 2316 KB | Output is correct |
31 | Correct | 68 ms | 2324 KB | Output is correct |
32 | Correct | 69 ms | 2260 KB | Output is correct |
33 | Correct | 70 ms | 2328 KB | Output is correct |
34 | Correct | 67 ms | 2324 KB | Output is correct |
35 | Correct | 66 ms | 2328 KB | Output is correct |
36 | Correct | 72 ms | 2316 KB | Output is correct |
37 | Correct | 133 ms | 2488 KB | Output is correct |
38 | Correct | 134 ms | 2444 KB | Output is correct |
39 | Correct | 189 ms | 2528 KB | Output is correct |
40 | Correct | 188 ms | 2576 KB | Output is correct |
41 | Correct | 183 ms | 2568 KB | Output is correct |
42 | Correct | 181 ms | 2528 KB | Output is correct |
43 | Correct | 169 ms | 2836 KB | Output is correct |
44 | Correct | 172 ms | 2896 KB | Output is correct |
45 | Correct | 168 ms | 2840 KB | Output is correct |
46 | Correct | 187 ms | 2380 KB | Output is correct |
47 | Correct | 183 ms | 2572 KB | Output is correct |
48 | Correct | 178 ms | 2764 KB | Output is correct |
49 | Correct | 178 ms | 2572 KB | Output is correct |
50 | Correct | 178 ms | 2552 KB | Output is correct |
51 | Correct | 64 ms | 1236 KB | Output is correct |
52 | Correct | 189 ms | 2956 KB | Output is correct |
53 | Correct | 210 ms | 2728 KB | Output is correct |
54 | Correct | 237 ms | 2828 KB | Output is correct |
55 | Correct | 244 ms | 3220 KB | Output is correct |
56 | Correct | 218 ms | 2972 KB | Output is correct |
57 | Correct | 250 ms | 3376 KB | Output is correct |
58 | Correct | 245 ms | 2968 KB | Output is correct |
59 | Correct | 244 ms | 2972 KB | Output is correct |
60 | Correct | 88 ms | 1236 KB | Output is correct |
61 | Correct | 251 ms | 3124 KB | Output is correct |
62 | Correct | 247 ms | 3164 KB | Output is correct |
63 | Correct | 224 ms | 3196 KB | Output is correct |
64 | Correct | 223 ms | 3208 KB | Output is correct |
65 | Correct | 217 ms | 2380 KB | Output is correct |
66 | Correct | 209 ms | 2588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2260 KB | Output is correct |
2 | Correct | 6 ms | 2228 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 5 ms | 2260 KB | Output is correct |
5 | Correct | 10 ms | 2308 KB | Output is correct |
6 | Correct | 8 ms | 2224 KB | Output is correct |
7 | Correct | 8 ms | 2260 KB | Output is correct |
8 | Correct | 10 ms | 2260 KB | Output is correct |
9 | Correct | 9 ms | 2260 KB | Output is correct |
10 | Correct | 22 ms | 2260 KB | Output is correct |
11 | Correct | 24 ms | 2212 KB | Output is correct |
12 | Correct | 23 ms | 2300 KB | Output is correct |
13 | Correct | 20 ms | 2204 KB | Output is correct |
14 | Correct | 22 ms | 2260 KB | Output is correct |
15 | Correct | 26 ms | 2292 KB | Output is correct |
16 | Correct | 25 ms | 2260 KB | Output is correct |
17 | Correct | 15 ms | 2260 KB | Output is correct |
18 | Correct | 18 ms | 2304 KB | Output is correct |
19 | Correct | 21 ms | 2308 KB | Output is correct |
20 | Correct | 22 ms | 2204 KB | Output is correct |
21 | Correct | 46 ms | 2212 KB | Output is correct |
22 | Correct | 51 ms | 2304 KB | Output is correct |
23 | Correct | 42 ms | 2208 KB | Output is correct |
24 | Correct | 75 ms | 2324 KB | Output is correct |
25 | Correct | 67 ms | 2252 KB | Output is correct |
26 | Correct | 71 ms | 2336 KB | Output is correct |
27 | Correct | 69 ms | 2320 KB | Output is correct |
28 | Correct | 69 ms | 2252 KB | Output is correct |
29 | Correct | 72 ms | 2448 KB | Output is correct |
30 | Correct | 70 ms | 2316 KB | Output is correct |
31 | Correct | 68 ms | 2324 KB | Output is correct |
32 | Correct | 69 ms | 2260 KB | Output is correct |
33 | Correct | 70 ms | 2328 KB | Output is correct |
34 | Correct | 67 ms | 2324 KB | Output is correct |
35 | Correct | 66 ms | 2328 KB | Output is correct |
36 | Correct | 72 ms | 2316 KB | Output is correct |
37 | Correct | 133 ms | 2488 KB | Output is correct |
38 | Correct | 134 ms | 2444 KB | Output is correct |
39 | Correct | 189 ms | 2528 KB | Output is correct |
40 | Correct | 188 ms | 2576 KB | Output is correct |
41 | Correct | 183 ms | 2568 KB | Output is correct |
42 | Correct | 181 ms | 2528 KB | Output is correct |
43 | Correct | 169 ms | 2836 KB | Output is correct |
44 | Correct | 172 ms | 2896 KB | Output is correct |
45 | Correct | 168 ms | 2840 KB | Output is correct |
46 | Correct | 187 ms | 2380 KB | Output is correct |
47 | Correct | 183 ms | 2572 KB | Output is correct |
48 | Correct | 178 ms | 2764 KB | Output is correct |
49 | Correct | 178 ms | 2572 KB | Output is correct |
50 | Correct | 178 ms | 2552 KB | Output is correct |
51 | Correct | 64 ms | 1236 KB | Output is correct |
52 | Correct | 189 ms | 2956 KB | Output is correct |
53 | Correct | 210 ms | 2728 KB | Output is correct |
54 | Correct | 237 ms | 2828 KB | Output is correct |
55 | Correct | 244 ms | 3220 KB | Output is correct |
56 | Correct | 218 ms | 2972 KB | Output is correct |
57 | Correct | 250 ms | 3376 KB | Output is correct |
58 | Correct | 245 ms | 2968 KB | Output is correct |
59 | Correct | 244 ms | 2972 KB | Output is correct |
60 | Correct | 88 ms | 1236 KB | Output is correct |
61 | Correct | 251 ms | 3124 KB | Output is correct |
62 | Correct | 247 ms | 3164 KB | Output is correct |
63 | Correct | 224 ms | 3196 KB | Output is correct |
64 | Correct | 223 ms | 3208 KB | Output is correct |
65 | Correct | 217 ms | 2380 KB | Output is correct |
66 | Correct | 209 ms | 2588 KB | Output is correct |
67 | Correct | 282 ms | 3016 KB | Output is correct |
68 | Correct | 126 ms | 1288 KB | Output is correct |
69 | Correct | 372 ms | 4252 KB | Output is correct |
70 | Correct | 358 ms | 3492 KB | Output is correct |
71 | Correct | 352 ms | 3408 KB | Output is correct |
72 | Correct | 356 ms | 2840 KB | Output is correct |
73 | Correct | 344 ms | 2708 KB | Output is correct |
74 | Correct | 377 ms | 4308 KB | Output is correct |
75 | Correct | 372 ms | 3972 KB | Output is correct |
76 | Correct | 384 ms | 4484 KB | Output is correct |
77 | Correct | 378 ms | 4420 KB | Output is correct |