Submission #1011729

# Submission time Handle Problem Language Result Execution time Memory
1011729 2024-07-01T07:41:29 Z Aiperiii Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 4436 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];
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;
    }
    map <int,int> mp;
    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(auto x : mp){
        if(x.ss==n)ans.pb(x.ff);
    }
    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

*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 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 2 ms 604 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 7 ms 604 KB Output is correct
25 Correct 15 ms 860 KB Output is correct
26 Correct 18 ms 796 KB Output is correct
27 Correct 10 ms 604 KB Output is correct
28 Correct 6 ms 604 KB Output is correct
29 Correct 11 ms 604 KB Output is correct
30 Correct 13 ms 604 KB Output is correct
31 Correct 16 ms 752 KB Output is correct
32 Correct 8 ms 604 KB Output is correct
33 Correct 3 ms 536 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 11 ms 604 KB Output is correct
36 Correct 9 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 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 2 ms 604 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 7 ms 604 KB Output is correct
25 Correct 15 ms 860 KB Output is correct
26 Correct 18 ms 796 KB Output is correct
27 Correct 10 ms 604 KB Output is correct
28 Correct 6 ms 604 KB Output is correct
29 Correct 11 ms 604 KB Output is correct
30 Correct 13 ms 604 KB Output is correct
31 Correct 16 ms 752 KB Output is correct
32 Correct 8 ms 604 KB Output is correct
33 Correct 3 ms 536 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 11 ms 604 KB Output is correct
36 Correct 9 ms 604 KB Output is correct
37 Correct 116 ms 1472 KB Output is correct
38 Correct 119 ms 1492 KB Output is correct
39 Correct 43 ms 948 KB Output is correct
40 Correct 282 ms 1968 KB Output is correct
41 Correct 59 ms 864 KB Output is correct
42 Correct 224 ms 1876 KB Output is correct
43 Correct 449 ms 3028 KB Output is correct
44 Correct 461 ms 3024 KB Output is correct
45 Correct 456 ms 3028 KB Output is correct
46 Correct 114 ms 1676 KB Output is correct
47 Correct 263 ms 2128 KB Output is correct
48 Correct 380 ms 2988 KB Output is correct
49 Correct 254 ms 2396 KB Output is correct
50 Correct 239 ms 1996 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 641 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 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 2 ms 604 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 7 ms 604 KB Output is correct
25 Correct 15 ms 860 KB Output is correct
26 Correct 18 ms 796 KB Output is correct
27 Correct 10 ms 604 KB Output is correct
28 Correct 6 ms 604 KB Output is correct
29 Correct 11 ms 604 KB Output is correct
30 Correct 13 ms 604 KB Output is correct
31 Correct 16 ms 752 KB Output is correct
32 Correct 8 ms 604 KB Output is correct
33 Correct 3 ms 536 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 11 ms 604 KB Output is correct
36 Correct 9 ms 604 KB Output is correct
37 Correct 116 ms 1472 KB Output is correct
38 Correct 119 ms 1492 KB Output is correct
39 Correct 43 ms 948 KB Output is correct
40 Correct 282 ms 1968 KB Output is correct
41 Correct 59 ms 864 KB Output is correct
42 Correct 224 ms 1876 KB Output is correct
43 Correct 449 ms 3028 KB Output is correct
44 Correct 461 ms 3024 KB Output is correct
45 Correct 456 ms 3028 KB Output is correct
46 Correct 114 ms 1676 KB Output is correct
47 Correct 263 ms 2128 KB Output is correct
48 Correct 380 ms 2988 KB Output is correct
49 Correct 254 ms 2396 KB Output is correct
50 Correct 239 ms 1996 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 641 ms 3436 KB Output is correct
53 Correct 438 ms 2604 KB Output is correct
54 Correct 663 ms 3000 KB Output is correct
55 Execution timed out 1040 ms 4436 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 464 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 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 2 ms 604 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 7 ms 604 KB Output is correct
25 Correct 15 ms 860 KB Output is correct
26 Correct 18 ms 796 KB Output is correct
27 Correct 10 ms 604 KB Output is correct
28 Correct 6 ms 604 KB Output is correct
29 Correct 11 ms 604 KB Output is correct
30 Correct 13 ms 604 KB Output is correct
31 Correct 16 ms 752 KB Output is correct
32 Correct 8 ms 604 KB Output is correct
33 Correct 3 ms 536 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 11 ms 604 KB Output is correct
36 Correct 9 ms 604 KB Output is correct
37 Correct 116 ms 1472 KB Output is correct
38 Correct 119 ms 1492 KB Output is correct
39 Correct 43 ms 948 KB Output is correct
40 Correct 282 ms 1968 KB Output is correct
41 Correct 59 ms 864 KB Output is correct
42 Correct 224 ms 1876 KB Output is correct
43 Correct 449 ms 3028 KB Output is correct
44 Correct 461 ms 3024 KB Output is correct
45 Correct 456 ms 3028 KB Output is correct
46 Correct 114 ms 1676 KB Output is correct
47 Correct 263 ms 2128 KB Output is correct
48 Correct 380 ms 2988 KB Output is correct
49 Correct 254 ms 2396 KB Output is correct
50 Correct 239 ms 1996 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 641 ms 3436 KB Output is correct
53 Correct 438 ms 2604 KB Output is correct
54 Correct 663 ms 3000 KB Output is correct
55 Execution timed out 1040 ms 4436 KB Time limit exceeded
56 Halted 0 ms 0 KB -