Submission #671176

# Submission time Handle Problem Language Result Execution time Memory
671176 2022-12-12T09:27:43 Z irmuun Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 123084 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    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:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 704 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 704 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2112 KB Output is correct
16 Correct 1 ms 2368 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 1856 KB Output is correct
20 Correct 2 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 704 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2112 KB Output is correct
16 Correct 1 ms 2368 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 1856 KB Output is correct
20 Correct 2 ms 2264 KB Output is correct
21 Correct 9 ms 8896 KB Output is correct
22 Correct 11 ms 11732 KB Output is correct
23 Correct 5 ms 5696 KB Output is correct
24 Correct 21 ms 18520 KB Output is correct
25 Correct 51 ms 18520 KB Output is correct
26 Correct 61 ms 20820 KB Output is correct
27 Correct 55 ms 20860 KB Output is correct
28 Correct 57 ms 20856 KB Output is correct
29 Correct 60 ms 20848 KB Output is correct
30 Correct 25 ms 20864 KB Output is correct
31 Correct 45 ms 20852 KB Output is correct
32 Correct 23 ms 20820 KB Output is correct
33 Correct 50 ms 20832 KB Output is correct
34 Correct 49 ms 20820 KB Output is correct
35 Correct 57 ms 20848 KB Output is correct
36 Correct 21 ms 20820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 704 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2112 KB Output is correct
16 Correct 1 ms 2368 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 1856 KB Output is correct
20 Correct 2 ms 2264 KB Output is correct
21 Correct 9 ms 8896 KB Output is correct
22 Correct 11 ms 11732 KB Output is correct
23 Correct 5 ms 5696 KB Output is correct
24 Correct 21 ms 18520 KB Output is correct
25 Correct 51 ms 18520 KB Output is correct
26 Correct 61 ms 20820 KB Output is correct
27 Correct 55 ms 20860 KB Output is correct
28 Correct 57 ms 20856 KB Output is correct
29 Correct 60 ms 20848 KB Output is correct
30 Correct 25 ms 20864 KB Output is correct
31 Correct 45 ms 20852 KB Output is correct
32 Correct 23 ms 20820 KB Output is correct
33 Correct 50 ms 20832 KB Output is correct
34 Correct 49 ms 20820 KB Output is correct
35 Correct 57 ms 20848 KB Output is correct
36 Correct 21 ms 20820 KB Output is correct
37 Correct 344 ms 80660 KB Output is correct
38 Correct 347 ms 80664 KB Output is correct
39 Execution timed out 1100 ms 123084 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 704 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2112 KB Output is correct
16 Correct 1 ms 2368 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 1856 KB Output is correct
20 Correct 2 ms 2264 KB Output is correct
21 Correct 9 ms 8896 KB Output is correct
22 Correct 11 ms 11732 KB Output is correct
23 Correct 5 ms 5696 KB Output is correct
24 Correct 21 ms 18520 KB Output is correct
25 Correct 51 ms 18520 KB Output is correct
26 Correct 61 ms 20820 KB Output is correct
27 Correct 55 ms 20860 KB Output is correct
28 Correct 57 ms 20856 KB Output is correct
29 Correct 60 ms 20848 KB Output is correct
30 Correct 25 ms 20864 KB Output is correct
31 Correct 45 ms 20852 KB Output is correct
32 Correct 23 ms 20820 KB Output is correct
33 Correct 50 ms 20832 KB Output is correct
34 Correct 49 ms 20820 KB Output is correct
35 Correct 57 ms 20848 KB Output is correct
36 Correct 21 ms 20820 KB Output is correct
37 Correct 344 ms 80660 KB Output is correct
38 Correct 347 ms 80664 KB Output is correct
39 Execution timed out 1100 ms 123084 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 704 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 2004 KB Output is correct
15 Correct 1 ms 2112 KB Output is correct
16 Correct 1 ms 2368 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 1856 KB Output is correct
20 Correct 2 ms 2264 KB Output is correct
21 Correct 9 ms 8896 KB Output is correct
22 Correct 11 ms 11732 KB Output is correct
23 Correct 5 ms 5696 KB Output is correct
24 Correct 21 ms 18520 KB Output is correct
25 Correct 51 ms 18520 KB Output is correct
26 Correct 61 ms 20820 KB Output is correct
27 Correct 55 ms 20860 KB Output is correct
28 Correct 57 ms 20856 KB Output is correct
29 Correct 60 ms 20848 KB Output is correct
30 Correct 25 ms 20864 KB Output is correct
31 Correct 45 ms 20852 KB Output is correct
32 Correct 23 ms 20820 KB Output is correct
33 Correct 50 ms 20832 KB Output is correct
34 Correct 49 ms 20820 KB Output is correct
35 Correct 57 ms 20848 KB Output is correct
36 Correct 21 ms 20820 KB Output is correct
37 Correct 344 ms 80660 KB Output is correct
38 Correct 347 ms 80664 KB Output is correct
39 Execution timed out 1100 ms 123084 KB Time limit exceeded
40 Halted 0 ms 0 KB -