Submission #566288

# Submission time Handle Problem Language Result Execution time Memory
566288 2022-05-22T08:14:03 Z birthdaycake Bootfall (IZhO17_bootfall) C++17
28 / 100
873 ms 1996 KB
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
 
 
 

int a[200001],dp[20001];
signed main(){
    boost;
    
    
    
    int n,  sum = 0; cin >> n;
    
    map<int,int>o;
    
    
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < n; i++){
        vector<int>x;
        map<int,int>freq;
        
        
        sum -= a[i];
        
        for(int j = 1; j <= 10000; j++) dp[j] = 0;
        
        for(int j = 0; j < n; j++){
            if(i != j) x.push_back(a[j]);
        }
        dp[0] = 1;
        for(int j = 0; j < n - 1; j++){
            for(int k = 10000; k >= 1; k--){
                if(k - x[j] >= 0) {
                    dp[k] += dp[k - x[j]];
                }
            }
            
            
        }
        //cout << sum << ' ' << i << endl;
        for(int j = 1; j <= sum; j++){
            if(dp[j]){
                int x = abs(j - sum);
                
                freq[abs(x - j)]++;
                //cout <<  abs(x - j) << ' ';
                if(freq[abs(j - x)] == 1){
                    o[abs(j - x)]++;
                }
            }
        }
        //cout << endl;
        sum += a[i];
        
    }
    for(int i = 1; i <= 10000; i++) dp[i] = 0;
    for(int i = 0; i < n; i++){
        for(int k = 10000; k >= 1; k--){
            if(k - a[i] >= 0){
                dp[k] += dp[k - a[i]];
            }
        }
    }
    if(sum % 2 || dp[sum / 2] == 0){
        cout << 0;
        return 0;
    }
    
    
    vector<int>ans;
    for(auto s:o){
        if(s.second == n){
            ans.push_back(s.first);
        }
    }
    cout << ans.size() << endl;
    for(auto s:ans){
        cout << s << ' ';
    }
    return 0;
}
# 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 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 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 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 8 ms 340 KB Output is correct
11 Correct 9 ms 340 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 11 ms 424 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 7 ms 324 KB Output is correct
20 Correct 10 ms 328 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 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 8 ms 340 KB Output is correct
11 Correct 9 ms 340 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 11 ms 424 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 7 ms 324 KB Output is correct
20 Correct 10 ms 328 KB Output is correct
21 Correct 60 ms 596 KB Output is correct
22 Correct 70 ms 616 KB Output is correct
23 Correct 34 ms 468 KB Output is correct
24 Correct 136 ms 716 KB Output is correct
25 Correct 165 ms 856 KB Output is correct
26 Correct 162 ms 960 KB Output is correct
27 Correct 131 ms 660 KB Output is correct
28 Correct 118 ms 632 KB Output is correct
29 Correct 137 ms 760 KB Output is correct
30 Correct 149 ms 852 KB Output is correct
31 Correct 176 ms 860 KB Output is correct
32 Correct 136 ms 704 KB Output is correct
33 Correct 74 ms 396 KB Output is correct
34 Correct 74 ms 400 KB Output is correct
35 Correct 115 ms 724 KB Output is correct
36 Correct 133 ms 688 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 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 8 ms 340 KB Output is correct
11 Correct 9 ms 340 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 11 ms 424 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 7 ms 324 KB Output is correct
20 Correct 10 ms 328 KB Output is correct
21 Correct 60 ms 596 KB Output is correct
22 Correct 70 ms 616 KB Output is correct
23 Correct 34 ms 468 KB Output is correct
24 Correct 136 ms 716 KB Output is correct
25 Correct 165 ms 856 KB Output is correct
26 Correct 162 ms 960 KB Output is correct
27 Correct 131 ms 660 KB Output is correct
28 Correct 118 ms 632 KB Output is correct
29 Correct 137 ms 760 KB Output is correct
30 Correct 149 ms 852 KB Output is correct
31 Correct 176 ms 860 KB Output is correct
32 Correct 136 ms 704 KB Output is correct
33 Correct 74 ms 396 KB Output is correct
34 Correct 74 ms 400 KB Output is correct
35 Correct 115 ms 724 KB Output is correct
36 Correct 133 ms 688 KB Output is correct
37 Correct 864 ms 1720 KB Output is correct
38 Correct 873 ms 1996 KB Output is correct
39 Incorrect 466 ms 428 KB Output isn't correct
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 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 8 ms 340 KB Output is correct
11 Correct 9 ms 340 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 11 ms 424 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 7 ms 324 KB Output is correct
20 Correct 10 ms 328 KB Output is correct
21 Correct 60 ms 596 KB Output is correct
22 Correct 70 ms 616 KB Output is correct
23 Correct 34 ms 468 KB Output is correct
24 Correct 136 ms 716 KB Output is correct
25 Correct 165 ms 856 KB Output is correct
26 Correct 162 ms 960 KB Output is correct
27 Correct 131 ms 660 KB Output is correct
28 Correct 118 ms 632 KB Output is correct
29 Correct 137 ms 760 KB Output is correct
30 Correct 149 ms 852 KB Output is correct
31 Correct 176 ms 860 KB Output is correct
32 Correct 136 ms 704 KB Output is correct
33 Correct 74 ms 396 KB Output is correct
34 Correct 74 ms 400 KB Output is correct
35 Correct 115 ms 724 KB Output is correct
36 Correct 133 ms 688 KB Output is correct
37 Correct 864 ms 1720 KB Output is correct
38 Correct 873 ms 1996 KB Output is correct
39 Incorrect 466 ms 428 KB Output isn't correct
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 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 8 ms 340 KB Output is correct
11 Correct 9 ms 340 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 11 ms 424 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 7 ms 324 KB Output is correct
20 Correct 10 ms 328 KB Output is correct
21 Correct 60 ms 596 KB Output is correct
22 Correct 70 ms 616 KB Output is correct
23 Correct 34 ms 468 KB Output is correct
24 Correct 136 ms 716 KB Output is correct
25 Correct 165 ms 856 KB Output is correct
26 Correct 162 ms 960 KB Output is correct
27 Correct 131 ms 660 KB Output is correct
28 Correct 118 ms 632 KB Output is correct
29 Correct 137 ms 760 KB Output is correct
30 Correct 149 ms 852 KB Output is correct
31 Correct 176 ms 860 KB Output is correct
32 Correct 136 ms 704 KB Output is correct
33 Correct 74 ms 396 KB Output is correct
34 Correct 74 ms 400 KB Output is correct
35 Correct 115 ms 724 KB Output is correct
36 Correct 133 ms 688 KB Output is correct
37 Correct 864 ms 1720 KB Output is correct
38 Correct 873 ms 1996 KB Output is correct
39 Incorrect 466 ms 428 KB Output isn't correct
40 Halted 0 ms 0 KB -