Submission #459598

# Submission time Handle Problem Language Result Execution time Memory
459598 2021-08-08T17:43:58 Z JovanB Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 4388 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int N = 500;
const int ofs = N*N;
const int MOD = 1000000007;

int add(int a, int b){ a += b; if(a >= MOD) a -= MOD; return a; }
int sub(int a, int b){ return add(a, MOD - b); }

int moze[N*N+5];
int dp[2*N*N+5];
int a[N+5];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    int poc = 0;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        poc -= a[i];
        a[i] *= 2;
    }
    dp[ofs + poc] = 1;
    for(int i=1; i<=n; i++){
        for(int j=N*N; j>=-N*N+a[i]; j--){
            dp[ofs + j] = add(dp[ofs + j], dp[ofs + j - a[i]]);
        }
    }
    if(dp[ofs] == 0){
        cout << "0\n";
        return 0;
    }
    for(int i=1; i<=n; i++){
        for(int j=-N*N+a[i]; j<=N*N; j++){
            dp[ofs + j] = sub(dp[ofs + j], dp[ofs + j - a[i]]);
        }
        for(int j=1; j<=N*N; j++) moze[j] += (dp[ofs + j - a[i]/2] > 0);
        for(int j=N*N; j>=-N*N+a[i]; j--){
            dp[ofs + j] = add(dp[ofs + j], dp[ofs + j - a[i]]);
        }
    }
    vector <int> vec;
    for(int i=1; i<=N*N; i++) if(moze[i] == n) vec.push_back(i);
    cout << vec.size() << "\n";
    for(auto c : vec) cout << c << " ";
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3148 KB Output is correct
2 Correct 15 ms 3252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 11 ms 3276 KB Output is correct
5 Correct 29 ms 3244 KB Output is correct
6 Correct 19 ms 3256 KB Output is correct
7 Correct 15 ms 3244 KB Output is correct
8 Correct 27 ms 3256 KB Output is correct
9 Correct 23 ms 3148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3148 KB Output is correct
2 Correct 15 ms 3252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 11 ms 3276 KB Output is correct
5 Correct 29 ms 3244 KB Output is correct
6 Correct 19 ms 3256 KB Output is correct
7 Correct 15 ms 3244 KB Output is correct
8 Correct 27 ms 3256 KB Output is correct
9 Correct 23 ms 3148 KB Output is correct
10 Correct 62 ms 3228 KB Output is correct
11 Correct 62 ms 3148 KB Output is correct
12 Correct 62 ms 3236 KB Output is correct
13 Correct 54 ms 3176 KB Output is correct
14 Correct 58 ms 3236 KB Output is correct
15 Correct 60 ms 3168 KB Output is correct
16 Correct 74 ms 3232 KB Output is correct
17 Correct 38 ms 3172 KB Output is correct
18 Correct 49 ms 3172 KB Output is correct
19 Correct 54 ms 3248 KB Output is correct
20 Correct 61 ms 3284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3148 KB Output is correct
2 Correct 15 ms 3252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 11 ms 3276 KB Output is correct
5 Correct 29 ms 3244 KB Output is correct
6 Correct 19 ms 3256 KB Output is correct
7 Correct 15 ms 3244 KB Output is correct
8 Correct 27 ms 3256 KB Output is correct
9 Correct 23 ms 3148 KB Output is correct
10 Correct 62 ms 3228 KB Output is correct
11 Correct 62 ms 3148 KB Output is correct
12 Correct 62 ms 3236 KB Output is correct
13 Correct 54 ms 3176 KB Output is correct
14 Correct 58 ms 3236 KB Output is correct
15 Correct 60 ms 3168 KB Output is correct
16 Correct 74 ms 3232 KB Output is correct
17 Correct 38 ms 3172 KB Output is correct
18 Correct 49 ms 3172 KB Output is correct
19 Correct 54 ms 3248 KB Output is correct
20 Correct 61 ms 3284 KB Output is correct
21 Correct 142 ms 3172 KB Output is correct
22 Correct 151 ms 3232 KB Output is correct
23 Correct 122 ms 3176 KB Output is correct
24 Correct 189 ms 3232 KB Output is correct
25 Correct 188 ms 3244 KB Output is correct
26 Correct 204 ms 3232 KB Output is correct
27 Correct 195 ms 3140 KB Output is correct
28 Correct 194 ms 3152 KB Output is correct
29 Correct 198 ms 3160 KB Output is correct
30 Correct 202 ms 3232 KB Output is correct
31 Correct 195 ms 3272 KB Output is correct
32 Correct 200 ms 3288 KB Output is correct
33 Correct 217 ms 3236 KB Output is correct
34 Correct 195 ms 3228 KB Output is correct
35 Correct 215 ms 3228 KB Output is correct
36 Correct 204 ms 3272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3148 KB Output is correct
2 Correct 15 ms 3252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 11 ms 3276 KB Output is correct
5 Correct 29 ms 3244 KB Output is correct
6 Correct 19 ms 3256 KB Output is correct
7 Correct 15 ms 3244 KB Output is correct
8 Correct 27 ms 3256 KB Output is correct
9 Correct 23 ms 3148 KB Output is correct
10 Correct 62 ms 3228 KB Output is correct
11 Correct 62 ms 3148 KB Output is correct
12 Correct 62 ms 3236 KB Output is correct
13 Correct 54 ms 3176 KB Output is correct
14 Correct 58 ms 3236 KB Output is correct
15 Correct 60 ms 3168 KB Output is correct
16 Correct 74 ms 3232 KB Output is correct
17 Correct 38 ms 3172 KB Output is correct
18 Correct 49 ms 3172 KB Output is correct
19 Correct 54 ms 3248 KB Output is correct
20 Correct 61 ms 3284 KB Output is correct
21 Correct 142 ms 3172 KB Output is correct
22 Correct 151 ms 3232 KB Output is correct
23 Correct 122 ms 3176 KB Output is correct
24 Correct 189 ms 3232 KB Output is correct
25 Correct 188 ms 3244 KB Output is correct
26 Correct 204 ms 3232 KB Output is correct
27 Correct 195 ms 3140 KB Output is correct
28 Correct 194 ms 3152 KB Output is correct
29 Correct 198 ms 3160 KB Output is correct
30 Correct 202 ms 3232 KB Output is correct
31 Correct 195 ms 3272 KB Output is correct
32 Correct 200 ms 3288 KB Output is correct
33 Correct 217 ms 3236 KB Output is correct
34 Correct 195 ms 3228 KB Output is correct
35 Correct 215 ms 3228 KB Output is correct
36 Correct 204 ms 3272 KB Output is correct
37 Correct 395 ms 3360 KB Output is correct
38 Correct 409 ms 3360 KB Output is correct
39 Correct 498 ms 3228 KB Output is correct
40 Correct 533 ms 3368 KB Output is correct
41 Correct 602 ms 3236 KB Output is correct
42 Correct 493 ms 3356 KB Output is correct
43 Correct 490 ms 3616 KB Output is correct
44 Correct 494 ms 3536 KB Output is correct
45 Correct 495 ms 3608 KB Output is correct
46 Correct 553 ms 3280 KB Output is correct
47 Correct 499 ms 3408 KB Output is correct
48 Correct 503 ms 3552 KB Output is correct
49 Correct 499 ms 3268 KB Output is correct
50 Correct 503 ms 3364 KB Output is correct
51 Correct 141 ms 2260 KB Output is correct
52 Correct 540 ms 3664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3148 KB Output is correct
2 Correct 15 ms 3252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 11 ms 3276 KB Output is correct
5 Correct 29 ms 3244 KB Output is correct
6 Correct 19 ms 3256 KB Output is correct
7 Correct 15 ms 3244 KB Output is correct
8 Correct 27 ms 3256 KB Output is correct
9 Correct 23 ms 3148 KB Output is correct
10 Correct 62 ms 3228 KB Output is correct
11 Correct 62 ms 3148 KB Output is correct
12 Correct 62 ms 3236 KB Output is correct
13 Correct 54 ms 3176 KB Output is correct
14 Correct 58 ms 3236 KB Output is correct
15 Correct 60 ms 3168 KB Output is correct
16 Correct 74 ms 3232 KB Output is correct
17 Correct 38 ms 3172 KB Output is correct
18 Correct 49 ms 3172 KB Output is correct
19 Correct 54 ms 3248 KB Output is correct
20 Correct 61 ms 3284 KB Output is correct
21 Correct 142 ms 3172 KB Output is correct
22 Correct 151 ms 3232 KB Output is correct
23 Correct 122 ms 3176 KB Output is correct
24 Correct 189 ms 3232 KB Output is correct
25 Correct 188 ms 3244 KB Output is correct
26 Correct 204 ms 3232 KB Output is correct
27 Correct 195 ms 3140 KB Output is correct
28 Correct 194 ms 3152 KB Output is correct
29 Correct 198 ms 3160 KB Output is correct
30 Correct 202 ms 3232 KB Output is correct
31 Correct 195 ms 3272 KB Output is correct
32 Correct 200 ms 3288 KB Output is correct
33 Correct 217 ms 3236 KB Output is correct
34 Correct 195 ms 3228 KB Output is correct
35 Correct 215 ms 3228 KB Output is correct
36 Correct 204 ms 3272 KB Output is correct
37 Correct 395 ms 3360 KB Output is correct
38 Correct 409 ms 3360 KB Output is correct
39 Correct 498 ms 3228 KB Output is correct
40 Correct 533 ms 3368 KB Output is correct
41 Correct 602 ms 3236 KB Output is correct
42 Correct 493 ms 3356 KB Output is correct
43 Correct 490 ms 3616 KB Output is correct
44 Correct 494 ms 3536 KB Output is correct
45 Correct 495 ms 3608 KB Output is correct
46 Correct 553 ms 3280 KB Output is correct
47 Correct 499 ms 3408 KB Output is correct
48 Correct 503 ms 3552 KB Output is correct
49 Correct 499 ms 3268 KB Output is correct
50 Correct 503 ms 3364 KB Output is correct
51 Correct 141 ms 2260 KB Output is correct
52 Correct 540 ms 3664 KB Output is correct
53 Correct 586 ms 3460 KB Output is correct
54 Correct 769 ms 3616 KB Output is correct
55 Correct 693 ms 3748 KB Output is correct
56 Correct 599 ms 3612 KB Output is correct
57 Correct 717 ms 3872 KB Output is correct
58 Correct 693 ms 3620 KB Output is correct
59 Correct 722 ms 3620 KB Output is correct
60 Correct 198 ms 2260 KB Output is correct
61 Correct 693 ms 3800 KB Output is correct
62 Correct 639 ms 3796 KB Output is correct
63 Correct 672 ms 3744 KB Output is correct
64 Correct 624 ms 3744 KB Output is correct
65 Correct 625 ms 3228 KB Output is correct
66 Correct 628 ms 3280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3148 KB Output is correct
2 Correct 15 ms 3252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 11 ms 3276 KB Output is correct
5 Correct 29 ms 3244 KB Output is correct
6 Correct 19 ms 3256 KB Output is correct
7 Correct 15 ms 3244 KB Output is correct
8 Correct 27 ms 3256 KB Output is correct
9 Correct 23 ms 3148 KB Output is correct
10 Correct 62 ms 3228 KB Output is correct
11 Correct 62 ms 3148 KB Output is correct
12 Correct 62 ms 3236 KB Output is correct
13 Correct 54 ms 3176 KB Output is correct
14 Correct 58 ms 3236 KB Output is correct
15 Correct 60 ms 3168 KB Output is correct
16 Correct 74 ms 3232 KB Output is correct
17 Correct 38 ms 3172 KB Output is correct
18 Correct 49 ms 3172 KB Output is correct
19 Correct 54 ms 3248 KB Output is correct
20 Correct 61 ms 3284 KB Output is correct
21 Correct 142 ms 3172 KB Output is correct
22 Correct 151 ms 3232 KB Output is correct
23 Correct 122 ms 3176 KB Output is correct
24 Correct 189 ms 3232 KB Output is correct
25 Correct 188 ms 3244 KB Output is correct
26 Correct 204 ms 3232 KB Output is correct
27 Correct 195 ms 3140 KB Output is correct
28 Correct 194 ms 3152 KB Output is correct
29 Correct 198 ms 3160 KB Output is correct
30 Correct 202 ms 3232 KB Output is correct
31 Correct 195 ms 3272 KB Output is correct
32 Correct 200 ms 3288 KB Output is correct
33 Correct 217 ms 3236 KB Output is correct
34 Correct 195 ms 3228 KB Output is correct
35 Correct 215 ms 3228 KB Output is correct
36 Correct 204 ms 3272 KB Output is correct
37 Correct 395 ms 3360 KB Output is correct
38 Correct 409 ms 3360 KB Output is correct
39 Correct 498 ms 3228 KB Output is correct
40 Correct 533 ms 3368 KB Output is correct
41 Correct 602 ms 3236 KB Output is correct
42 Correct 493 ms 3356 KB Output is correct
43 Correct 490 ms 3616 KB Output is correct
44 Correct 494 ms 3536 KB Output is correct
45 Correct 495 ms 3608 KB Output is correct
46 Correct 553 ms 3280 KB Output is correct
47 Correct 499 ms 3408 KB Output is correct
48 Correct 503 ms 3552 KB Output is correct
49 Correct 499 ms 3268 KB Output is correct
50 Correct 503 ms 3364 KB Output is correct
51 Correct 141 ms 2260 KB Output is correct
52 Correct 540 ms 3664 KB Output is correct
53 Correct 586 ms 3460 KB Output is correct
54 Correct 769 ms 3616 KB Output is correct
55 Correct 693 ms 3748 KB Output is correct
56 Correct 599 ms 3612 KB Output is correct
57 Correct 717 ms 3872 KB Output is correct
58 Correct 693 ms 3620 KB Output is correct
59 Correct 722 ms 3620 KB Output is correct
60 Correct 198 ms 2260 KB Output is correct
61 Correct 693 ms 3800 KB Output is correct
62 Correct 639 ms 3796 KB Output is correct
63 Correct 672 ms 3744 KB Output is correct
64 Correct 624 ms 3744 KB Output is correct
65 Correct 625 ms 3228 KB Output is correct
66 Correct 628 ms 3280 KB Output is correct
67 Correct 832 ms 3676 KB Output is correct
68 Correct 283 ms 2252 KB Output is correct
69 Correct 983 ms 4388 KB Output is correct
70 Execution timed out 1004 ms 4000 KB Time limit exceeded
71 Halted 0 ms 0 KB -