답안 #1037534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037534 2024-07-29T03:27:11 Z ByeWorld Bootfall (IZhO17_bootfall) C++14
100 / 100
228 ms 5888 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;
const int MAXN = 505;
const int MAXA = 250100;
const int MAXK = 1e5+10;
const int INF = 1e18+10;
void chmn(int &a, int b){ a = min(a, b); }

int n;
int a[MAXN], sum;
vector <int> ans;
int dp[MAXA], can[MAXA];

signed main(){
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++){ cin >> a[i]; sum += a[i]; }

    dp[0] = 1;
    for(int i=1; i<=n; i++){
    	for(int j=sum; j>=a[i]; j--){
    		dp[j] += dp[j-a[i]];
    	}
    }
	if(sum%2==1 || !dp[sum/2]){
		cout << "0\n"; exit(0);
	}

	for(int i=1; i<=n; i++){
    	for(int j=a[i]; j<=sum; j++){
    		dp[j] -= dp[j-a[i]];
    	}
    	for(int x=1; x<=sum; x++){
    		int num = sum+x-a[i];
    		if(num%2==0 && dp[num/2]) can[x]++;
    	}
    	for(int j=sum; j>=a[i]; j--){
    		dp[j] += dp[j-a[i]];
    	}
	}

    for(int i=1; i<=sum; i++)
    	if(can[i]==n) ans.pb(i);
    cout << ans.size() << '\n';
    for(auto in : ans) cout << in << ' ';
    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2500 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2556 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 3 ms 2396 KB Output is correct
35 Correct 3 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2500 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2556 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 3 ms 2396 KB Output is correct
35 Correct 3 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 8 ms 2908 KB Output is correct
38 Correct 12 ms 2908 KB Output is correct
39 Correct 29 ms 2652 KB Output is correct
40 Correct 20 ms 2940 KB Output is correct
41 Correct 43 ms 2908 KB Output is correct
42 Correct 16 ms 2932 KB Output is correct
43 Correct 26 ms 3280 KB Output is correct
44 Correct 27 ms 3224 KB Output is correct
45 Correct 27 ms 3280 KB Output is correct
46 Correct 16 ms 2652 KB Output is correct
47 Correct 16 ms 2908 KB Output is correct
48 Correct 41 ms 3256 KB Output is correct
49 Correct 30 ms 2908 KB Output is correct
50 Correct 25 ms 2908 KB Output is correct
51 Correct 3 ms 2396 KB Output is correct
52 Correct 36 ms 3280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2500 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2556 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 3 ms 2396 KB Output is correct
35 Correct 3 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 8 ms 2908 KB Output is correct
38 Correct 12 ms 2908 KB Output is correct
39 Correct 29 ms 2652 KB Output is correct
40 Correct 20 ms 2940 KB Output is correct
41 Correct 43 ms 2908 KB Output is correct
42 Correct 16 ms 2932 KB Output is correct
43 Correct 26 ms 3280 KB Output is correct
44 Correct 27 ms 3224 KB Output is correct
45 Correct 27 ms 3280 KB Output is correct
46 Correct 16 ms 2652 KB Output is correct
47 Correct 16 ms 2908 KB Output is correct
48 Correct 41 ms 3256 KB Output is correct
49 Correct 30 ms 2908 KB Output is correct
50 Correct 25 ms 2908 KB Output is correct
51 Correct 3 ms 2396 KB Output is correct
52 Correct 36 ms 3280 KB Output is correct
53 Correct 26 ms 3024 KB Output is correct
54 Correct 36 ms 3212 KB Output is correct
55 Correct 92 ms 4044 KB Output is correct
56 Correct 33 ms 3280 KB Output is correct
57 Correct 77 ms 4044 KB Output is correct
58 Correct 41 ms 3280 KB Output is correct
59 Correct 69 ms 3540 KB Output is correct
60 Correct 8 ms 2652 KB Output is correct
61 Correct 57 ms 3688 KB Output is correct
62 Correct 57 ms 3788 KB Output is correct
63 Correct 62 ms 3792 KB Output is correct
64 Correct 66 ms 3792 KB Output is correct
65 Correct 32 ms 2652 KB Output is correct
66 Correct 33 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2500 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2556 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 3 ms 2396 KB Output is correct
35 Correct 3 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 8 ms 2908 KB Output is correct
38 Correct 12 ms 2908 KB Output is correct
39 Correct 29 ms 2652 KB Output is correct
40 Correct 20 ms 2940 KB Output is correct
41 Correct 43 ms 2908 KB Output is correct
42 Correct 16 ms 2932 KB Output is correct
43 Correct 26 ms 3280 KB Output is correct
44 Correct 27 ms 3224 KB Output is correct
45 Correct 27 ms 3280 KB Output is correct
46 Correct 16 ms 2652 KB Output is correct
47 Correct 16 ms 2908 KB Output is correct
48 Correct 41 ms 3256 KB Output is correct
49 Correct 30 ms 2908 KB Output is correct
50 Correct 25 ms 2908 KB Output is correct
51 Correct 3 ms 2396 KB Output is correct
52 Correct 36 ms 3280 KB Output is correct
53 Correct 26 ms 3024 KB Output is correct
54 Correct 36 ms 3212 KB Output is correct
55 Correct 92 ms 4044 KB Output is correct
56 Correct 33 ms 3280 KB Output is correct
57 Correct 77 ms 4044 KB Output is correct
58 Correct 41 ms 3280 KB Output is correct
59 Correct 69 ms 3540 KB Output is correct
60 Correct 8 ms 2652 KB Output is correct
61 Correct 57 ms 3688 KB Output is correct
62 Correct 57 ms 3788 KB Output is correct
63 Correct 62 ms 3792 KB Output is correct
64 Correct 66 ms 3792 KB Output is correct
65 Correct 32 ms 2652 KB Output is correct
66 Correct 33 ms 2900 KB Output is correct
67 Correct 62 ms 3536 KB Output is correct
68 Correct 23 ms 3164 KB Output is correct
69 Correct 202 ms 5520 KB Output is correct
70 Correct 120 ms 4300 KB Output is correct
71 Correct 120 ms 4244 KB Output is correct
72 Correct 133 ms 3356 KB Output is correct
73 Correct 120 ms 3164 KB Output is correct
74 Correct 205 ms 5576 KB Output is correct
75 Correct 173 ms 4884 KB Output is correct
76 Correct 225 ms 5688 KB Output is correct
77 Correct 228 ms 5888 KB Output is correct