Submission #671119

# Submission time Handle Problem Language Result Execution time Memory
671119 2022-12-12T04:39:06 Z irmuun Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 123052 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
    int n;
    cin>>n;
    int a[n+5];
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a+1,a+n+1);
    int dp[n+5][500*n+5];
    for(int i=0;i<=n;i++){
        fill(dp[i],dp[i]+500*n+1,0);
        dp[i][0]=1;
        int cur=0;
        for(int j=1;j<=n;j++){
            if(i==j){
                continue;
            }
            for(int k=cur;k>=0;k--){
                if(dp[i][k]==1){
                    dp[i][k+a[j]]=1;
                }
            }
            cur+=a[j];
        }
    }
    vector<int>ans;
    for(int i=1;i<=sum;i++){
        bool ok=true;
        for(int j=0;j<=n;j++){
            if(j==0){
                if(sum%2==1){
                    ok=false;
                    break;
                }
                if(dp[j][sum/2]==0){
                    ok=false;
                    break;
                }
            }
            else{
                if((sum+i-a[j])%2==1){
                    ok=false;
                    break;
                }
                if(dp[j][(sum+i-a[j])/2]==0){
                    ok=false;
                    break;
                }
            }
        }
        if(ok==true){
            ans.pb(i);
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<' ';
    }
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 2 ms 2244 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2004 KB Output is correct
16 Correct 1 ms 2348 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1620 KB Output is correct
19 Correct 1 ms 1836 KB Output is correct
20 Correct 2 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 2 ms 2244 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2004 KB Output is correct
16 Correct 1 ms 2348 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1620 KB Output is correct
19 Correct 1 ms 1836 KB Output is correct
20 Correct 2 ms 2260 KB Output is correct
21 Correct 8 ms 8916 KB Output is correct
22 Correct 12 ms 11692 KB Output is correct
23 Correct 4 ms 5684 KB Output is correct
24 Correct 21 ms 18504 KB Output is correct
25 Correct 45 ms 18508 KB Output is correct
26 Correct 54 ms 20820 KB Output is correct
27 Correct 49 ms 20820 KB Output is correct
28 Correct 53 ms 20828 KB Output is correct
29 Correct 56 ms 20836 KB Output is correct
30 Correct 23 ms 20820 KB Output is correct
31 Correct 37 ms 20784 KB Output is correct
32 Correct 26 ms 20836 KB Output is correct
33 Correct 51 ms 20820 KB Output is correct
34 Correct 50 ms 20844 KB Output is correct
35 Correct 55 ms 20828 KB Output is correct
36 Correct 22 ms 20820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 2 ms 2244 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2004 KB Output is correct
16 Correct 1 ms 2348 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1620 KB Output is correct
19 Correct 1 ms 1836 KB Output is correct
20 Correct 2 ms 2260 KB Output is correct
21 Correct 8 ms 8916 KB Output is correct
22 Correct 12 ms 11692 KB Output is correct
23 Correct 4 ms 5684 KB Output is correct
24 Correct 21 ms 18504 KB Output is correct
25 Correct 45 ms 18508 KB Output is correct
26 Correct 54 ms 20820 KB Output is correct
27 Correct 49 ms 20820 KB Output is correct
28 Correct 53 ms 20828 KB Output is correct
29 Correct 56 ms 20836 KB Output is correct
30 Correct 23 ms 20820 KB Output is correct
31 Correct 37 ms 20784 KB Output is correct
32 Correct 26 ms 20836 KB Output is correct
33 Correct 51 ms 20820 KB Output is correct
34 Correct 50 ms 20844 KB Output is correct
35 Correct 55 ms 20828 KB Output is correct
36 Correct 22 ms 20820 KB Output is correct
37 Correct 267 ms 80652 KB Output is correct
38 Correct 278 ms 80620 KB Output is correct
39 Execution timed out 1085 ms 123052 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 2 ms 2244 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2004 KB Output is correct
16 Correct 1 ms 2348 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1620 KB Output is correct
19 Correct 1 ms 1836 KB Output is correct
20 Correct 2 ms 2260 KB Output is correct
21 Correct 8 ms 8916 KB Output is correct
22 Correct 12 ms 11692 KB Output is correct
23 Correct 4 ms 5684 KB Output is correct
24 Correct 21 ms 18504 KB Output is correct
25 Correct 45 ms 18508 KB Output is correct
26 Correct 54 ms 20820 KB Output is correct
27 Correct 49 ms 20820 KB Output is correct
28 Correct 53 ms 20828 KB Output is correct
29 Correct 56 ms 20836 KB Output is correct
30 Correct 23 ms 20820 KB Output is correct
31 Correct 37 ms 20784 KB Output is correct
32 Correct 26 ms 20836 KB Output is correct
33 Correct 51 ms 20820 KB Output is correct
34 Correct 50 ms 20844 KB Output is correct
35 Correct 55 ms 20828 KB Output is correct
36 Correct 22 ms 20820 KB Output is correct
37 Correct 267 ms 80652 KB Output is correct
38 Correct 278 ms 80620 KB Output is correct
39 Execution timed out 1085 ms 123052 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 2 ms 2244 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2004 KB Output is correct
16 Correct 1 ms 2348 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1620 KB Output is correct
19 Correct 1 ms 1836 KB Output is correct
20 Correct 2 ms 2260 KB Output is correct
21 Correct 8 ms 8916 KB Output is correct
22 Correct 12 ms 11692 KB Output is correct
23 Correct 4 ms 5684 KB Output is correct
24 Correct 21 ms 18504 KB Output is correct
25 Correct 45 ms 18508 KB Output is correct
26 Correct 54 ms 20820 KB Output is correct
27 Correct 49 ms 20820 KB Output is correct
28 Correct 53 ms 20828 KB Output is correct
29 Correct 56 ms 20836 KB Output is correct
30 Correct 23 ms 20820 KB Output is correct
31 Correct 37 ms 20784 KB Output is correct
32 Correct 26 ms 20836 KB Output is correct
33 Correct 51 ms 20820 KB Output is correct
34 Correct 50 ms 20844 KB Output is correct
35 Correct 55 ms 20828 KB Output is correct
36 Correct 22 ms 20820 KB Output is correct
37 Correct 267 ms 80652 KB Output is correct
38 Correct 278 ms 80620 KB Output is correct
39 Execution timed out 1085 ms 123052 KB Time limit exceeded
40 Halted 0 ms 0 KB -