답안 #1011730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011730 2024-07-01T07:43:39 Z Aiperiii Bootfall (IZhO17_bootfall) C++14
100 / 100
329 ms 5836 KB
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int N=505;
int dp[N*500],mp[N*500];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector <int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    dp[0]=1;
    for(int i=0;i<n;i++){
        for(int j=sum;j>=a[i];j--){
            dp[j]+=dp[j-a[i]];
        }
    }
    if(sum%2==1 or !dp[sum/2]){
        cout<<0<<"\n";return 0;
    }
    for(int i=0;i<n;i++){
        for(int j=a[i];j<=sum;j++){
            dp[j]-=dp[j-a[i]];
        }
        for(int j=1;j<=sum-a[i];j++){
            if(j*2>sum-a[i] && dp[j]){
                mp[j*2-(sum-a[i])]++;
            }
        }
        
        for(int j=sum;j>=a[i];j--){
            dp[j]+=dp[j-a[i]];
        }
    }
    vector <int> ans;
    for(int i=1;i<=sum;i++){
        if(mp[i]==n)ans.pb(i);
    }
    cout<<ans.size()<<"\n";
    for(auto x : ans)cout<<x<<" ";
    cout<<'\n';
}
/*
 4
 1 3 1 5
 
 6
 3 5 7 11 9 13
 
 3
 2 2 2
 
 4
 200 200 200 200
 
 
 4 25
 1 2 3 4
 1 2 3 4
 12 6 3 4
 3 3
 19 4 5
 2 6 2
 
 5 60000
 630510219 369411957 874325200 990002527 567203997
 438920902 634940661 593780254 315929832 420627496

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 392 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 392 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 392 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 2 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 4 ms 600 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 2 ms 544 KB Output is correct
33 Correct 3 ms 608 KB Output is correct
34 Correct 3 ms 608 KB Output is correct
35 Correct 3 ms 608 KB Output is correct
36 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 392 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 2 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 4 ms 600 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 2 ms 544 KB Output is correct
33 Correct 3 ms 608 KB Output is correct
34 Correct 3 ms 608 KB Output is correct
35 Correct 3 ms 608 KB Output is correct
36 Correct 2 ms 608 KB Output is correct
37 Correct 12 ms 864 KB Output is correct
38 Correct 12 ms 1044 KB Output is correct
39 Correct 46 ms 1376 KB Output is correct
40 Correct 28 ms 1112 KB Output is correct
41 Correct 54 ms 1376 KB Output is correct
42 Correct 22 ms 1104 KB Output is correct
43 Correct 42 ms 1744 KB Output is correct
44 Correct 41 ms 1728 KB Output is correct
45 Correct 41 ms 1748 KB Output is correct
46 Correct 33 ms 860 KB Output is correct
47 Correct 23 ms 1116 KB Output is correct
48 Correct 44 ms 1812 KB Output is correct
49 Correct 42 ms 1420 KB Output is correct
50 Correct 24 ms 1108 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 53 ms 1948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 392 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 2 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 4 ms 600 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 2 ms 544 KB Output is correct
33 Correct 3 ms 608 KB Output is correct
34 Correct 3 ms 608 KB Output is correct
35 Correct 3 ms 608 KB Output is correct
36 Correct 2 ms 608 KB Output is correct
37 Correct 12 ms 864 KB Output is correct
38 Correct 12 ms 1044 KB Output is correct
39 Correct 46 ms 1376 KB Output is correct
40 Correct 28 ms 1112 KB Output is correct
41 Correct 54 ms 1376 KB Output is correct
42 Correct 22 ms 1104 KB Output is correct
43 Correct 42 ms 1744 KB Output is correct
44 Correct 41 ms 1728 KB Output is correct
45 Correct 41 ms 1748 KB Output is correct
46 Correct 33 ms 860 KB Output is correct
47 Correct 23 ms 1116 KB Output is correct
48 Correct 44 ms 1812 KB Output is correct
49 Correct 42 ms 1420 KB Output is correct
50 Correct 24 ms 1108 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 53 ms 1948 KB Output is correct
53 Correct 48 ms 1564 KB Output is correct
54 Correct 68 ms 1704 KB Output is correct
55 Correct 109 ms 2768 KB Output is correct
56 Correct 48 ms 1744 KB Output is correct
57 Correct 115 ms 3024 KB Output is correct
58 Correct 61 ms 1744 KB Output is correct
59 Correct 75 ms 2216 KB Output is correct
60 Correct 15 ms 860 KB Output is correct
61 Correct 118 ms 2432 KB Output is correct
62 Correct 108 ms 2512 KB Output is correct
63 Correct 94 ms 2868 KB Output is correct
64 Correct 91 ms 2688 KB Output is correct
65 Correct 37 ms 1112 KB Output is correct
66 Correct 49 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 392 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 2 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 4 ms 600 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 2 ms 544 KB Output is correct
33 Correct 3 ms 608 KB Output is correct
34 Correct 3 ms 608 KB Output is correct
35 Correct 3 ms 608 KB Output is correct
36 Correct 2 ms 608 KB Output is correct
37 Correct 12 ms 864 KB Output is correct
38 Correct 12 ms 1044 KB Output is correct
39 Correct 46 ms 1376 KB Output is correct
40 Correct 28 ms 1112 KB Output is correct
41 Correct 54 ms 1376 KB Output is correct
42 Correct 22 ms 1104 KB Output is correct
43 Correct 42 ms 1744 KB Output is correct
44 Correct 41 ms 1728 KB Output is correct
45 Correct 41 ms 1748 KB Output is correct
46 Correct 33 ms 860 KB Output is correct
47 Correct 23 ms 1116 KB Output is correct
48 Correct 44 ms 1812 KB Output is correct
49 Correct 42 ms 1420 KB Output is correct
50 Correct 24 ms 1108 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 53 ms 1948 KB Output is correct
53 Correct 48 ms 1564 KB Output is correct
54 Correct 68 ms 1704 KB Output is correct
55 Correct 109 ms 2768 KB Output is correct
56 Correct 48 ms 1744 KB Output is correct
57 Correct 115 ms 3024 KB Output is correct
58 Correct 61 ms 1744 KB Output is correct
59 Correct 75 ms 2216 KB Output is correct
60 Correct 15 ms 860 KB Output is correct
61 Correct 118 ms 2432 KB Output is correct
62 Correct 108 ms 2512 KB Output is correct
63 Correct 94 ms 2868 KB Output is correct
64 Correct 91 ms 2688 KB Output is correct
65 Correct 37 ms 1112 KB Output is correct
66 Correct 49 ms 1364 KB Output is correct
67 Correct 96 ms 2516 KB Output is correct
68 Correct 36 ms 1368 KB Output is correct
69 Correct 328 ms 5324 KB Output is correct
70 Correct 178 ms 3352 KB Output is correct
71 Correct 163 ms 3368 KB Output is correct
72 Correct 176 ms 2416 KB Output is correct
73 Correct 169 ms 2640 KB Output is correct
74 Correct 279 ms 5580 KB Output is correct
75 Correct 274 ms 4308 KB Output is correct
76 Correct 329 ms 5836 KB Output is correct
77 Correct 302 ms 5816 KB Output is correct