Submission #38238

# Submission time Handle Problem Language Result Execution time Memory
38238 2018-01-03T05:35:23 Z Talant Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 83232 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const ll inf = (ll)1e9 + 7;
const int N = (int)1e6 + 1;
const int M = (int)72901;

int n;
int dp[271][72901];
int a[N],sum;
vector <int> ans;

int main () {
        cin >> n;

        for (int i = 1; i <= n; i ++)
                cin >> a[i],sum += a[i];

        for (int i = 0; i <= n; i ++)
                memset(dp[i],-1,sizeof(dp[i]));

        for (int i = 0; i <= n; i ++) {
                dp[i][0] = 1;
                for (int j = 1; j <= n; j ++) {
                        if (j == i)
                                continue;
                        for (int k = sum; k >= a[j]; k --)
                                if (dp[i][k - a[j]] != -1)
                                        dp[i][k] = 1;
                }
        }

        for (int i = 1; i <= sum; i ++) {
                int f = 0;
                if (sum % 2 != 0 || dp[0][sum / 2] == -1)
                        continue;

                for (int j = 1; j <= n; j ++) {
                        if ((sum - a[j] + i) % 2 != 0 || (sum - a[j] + i) / 2 - i < 0 || dp[j][(sum - a[j] + i) / 2 - i] == -1 || dp[j][(sum - a[j] + i) / 2] == -1) {
                                f = 1;
                                break;
                        }
                }
                if (!f)
                        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:58:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < ans.size(); i ++)
                           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 83092 KB Output is correct
2 Correct 0 ms 83092 KB Output is correct
3 Correct 0 ms 83092 KB Output is correct
4 Correct 0 ms 83092 KB Output is correct
5 Correct 0 ms 83092 KB Output is correct
6 Correct 0 ms 83092 KB Output is correct
7 Correct 0 ms 83092 KB Output is correct
8 Correct 3 ms 83092 KB Output is correct
9 Correct 0 ms 83092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 83092 KB Output is correct
2 Correct 0 ms 83092 KB Output is correct
3 Correct 0 ms 83092 KB Output is correct
4 Correct 0 ms 83092 KB Output is correct
5 Correct 0 ms 83092 KB Output is correct
6 Correct 0 ms 83092 KB Output is correct
7 Correct 0 ms 83092 KB Output is correct
8 Correct 3 ms 83092 KB Output is correct
9 Correct 0 ms 83092 KB Output is correct
10 Correct 3 ms 83092 KB Output is correct
11 Correct 0 ms 83092 KB Output is correct
12 Correct 3 ms 83092 KB Output is correct
13 Correct 0 ms 83092 KB Output is correct
14 Correct 0 ms 83092 KB Output is correct
15 Correct 0 ms 83092 KB Output is correct
16 Correct 0 ms 83092 KB Output is correct
17 Correct 3 ms 83092 KB Output is correct
18 Correct 0 ms 83092 KB Output is correct
19 Correct 0 ms 83092 KB Output is correct
20 Correct 6 ms 83092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 83092 KB Output is correct
2 Correct 0 ms 83092 KB Output is correct
3 Correct 0 ms 83092 KB Output is correct
4 Correct 0 ms 83092 KB Output is correct
5 Correct 0 ms 83092 KB Output is correct
6 Correct 0 ms 83092 KB Output is correct
7 Correct 0 ms 83092 KB Output is correct
8 Correct 3 ms 83092 KB Output is correct
9 Correct 0 ms 83092 KB Output is correct
10 Correct 3 ms 83092 KB Output is correct
11 Correct 0 ms 83092 KB Output is correct
12 Correct 3 ms 83092 KB Output is correct
13 Correct 0 ms 83092 KB Output is correct
14 Correct 0 ms 83092 KB Output is correct
15 Correct 0 ms 83092 KB Output is correct
16 Correct 0 ms 83092 KB Output is correct
17 Correct 3 ms 83092 KB Output is correct
18 Correct 0 ms 83092 KB Output is correct
19 Correct 0 ms 83092 KB Output is correct
20 Correct 6 ms 83092 KB Output is correct
21 Correct 16 ms 83092 KB Output is correct
22 Correct 29 ms 83092 KB Output is correct
23 Correct 16 ms 83092 KB Output is correct
24 Correct 59 ms 83092 KB Output is correct
25 Correct 123 ms 83092 KB Output is correct
26 Correct 156 ms 83092 KB Output is correct
27 Correct 129 ms 83092 KB Output is correct
28 Correct 133 ms 83092 KB Output is correct
29 Correct 149 ms 83092 KB Output is correct
30 Correct 73 ms 83092 KB Output is correct
31 Correct 119 ms 83092 KB Output is correct
32 Correct 66 ms 83092 KB Output is correct
33 Correct 146 ms 83092 KB Output is correct
34 Correct 149 ms 83092 KB Output is correct
35 Correct 169 ms 83092 KB Output is correct
36 Correct 69 ms 83092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 83092 KB Output is correct
2 Correct 0 ms 83092 KB Output is correct
3 Correct 0 ms 83092 KB Output is correct
4 Correct 0 ms 83092 KB Output is correct
5 Correct 0 ms 83092 KB Output is correct
6 Correct 0 ms 83092 KB Output is correct
7 Correct 0 ms 83092 KB Output is correct
8 Correct 3 ms 83092 KB Output is correct
9 Correct 0 ms 83092 KB Output is correct
10 Correct 3 ms 83092 KB Output is correct
11 Correct 0 ms 83092 KB Output is correct
12 Correct 3 ms 83092 KB Output is correct
13 Correct 0 ms 83092 KB Output is correct
14 Correct 0 ms 83092 KB Output is correct
15 Correct 0 ms 83092 KB Output is correct
16 Correct 0 ms 83092 KB Output is correct
17 Correct 3 ms 83092 KB Output is correct
18 Correct 0 ms 83092 KB Output is correct
19 Correct 0 ms 83092 KB Output is correct
20 Correct 6 ms 83092 KB Output is correct
21 Correct 16 ms 83092 KB Output is correct
22 Correct 29 ms 83092 KB Output is correct
23 Correct 16 ms 83092 KB Output is correct
24 Correct 59 ms 83092 KB Output is correct
25 Correct 123 ms 83092 KB Output is correct
26 Correct 156 ms 83092 KB Output is correct
27 Correct 129 ms 83092 KB Output is correct
28 Correct 133 ms 83092 KB Output is correct
29 Correct 149 ms 83092 KB Output is correct
30 Correct 73 ms 83092 KB Output is correct
31 Correct 119 ms 83092 KB Output is correct
32 Correct 66 ms 83092 KB Output is correct
33 Correct 146 ms 83092 KB Output is correct
34 Correct 149 ms 83092 KB Output is correct
35 Correct 169 ms 83092 KB Output is correct
36 Correct 69 ms 83092 KB Output is correct
37 Execution timed out 1000 ms 83232 KB Execution timed out
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 83092 KB Output is correct
2 Correct 0 ms 83092 KB Output is correct
3 Correct 0 ms 83092 KB Output is correct
4 Correct 0 ms 83092 KB Output is correct
5 Correct 0 ms 83092 KB Output is correct
6 Correct 0 ms 83092 KB Output is correct
7 Correct 0 ms 83092 KB Output is correct
8 Correct 3 ms 83092 KB Output is correct
9 Correct 0 ms 83092 KB Output is correct
10 Correct 3 ms 83092 KB Output is correct
11 Correct 0 ms 83092 KB Output is correct
12 Correct 3 ms 83092 KB Output is correct
13 Correct 0 ms 83092 KB Output is correct
14 Correct 0 ms 83092 KB Output is correct
15 Correct 0 ms 83092 KB Output is correct
16 Correct 0 ms 83092 KB Output is correct
17 Correct 3 ms 83092 KB Output is correct
18 Correct 0 ms 83092 KB Output is correct
19 Correct 0 ms 83092 KB Output is correct
20 Correct 6 ms 83092 KB Output is correct
21 Correct 16 ms 83092 KB Output is correct
22 Correct 29 ms 83092 KB Output is correct
23 Correct 16 ms 83092 KB Output is correct
24 Correct 59 ms 83092 KB Output is correct
25 Correct 123 ms 83092 KB Output is correct
26 Correct 156 ms 83092 KB Output is correct
27 Correct 129 ms 83092 KB Output is correct
28 Correct 133 ms 83092 KB Output is correct
29 Correct 149 ms 83092 KB Output is correct
30 Correct 73 ms 83092 KB Output is correct
31 Correct 119 ms 83092 KB Output is correct
32 Correct 66 ms 83092 KB Output is correct
33 Correct 146 ms 83092 KB Output is correct
34 Correct 149 ms 83092 KB Output is correct
35 Correct 169 ms 83092 KB Output is correct
36 Correct 69 ms 83092 KB Output is correct
37 Execution timed out 1000 ms 83232 KB Execution timed out
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 83092 KB Output is correct
2 Correct 0 ms 83092 KB Output is correct
3 Correct 0 ms 83092 KB Output is correct
4 Correct 0 ms 83092 KB Output is correct
5 Correct 0 ms 83092 KB Output is correct
6 Correct 0 ms 83092 KB Output is correct
7 Correct 0 ms 83092 KB Output is correct
8 Correct 3 ms 83092 KB Output is correct
9 Correct 0 ms 83092 KB Output is correct
10 Correct 3 ms 83092 KB Output is correct
11 Correct 0 ms 83092 KB Output is correct
12 Correct 3 ms 83092 KB Output is correct
13 Correct 0 ms 83092 KB Output is correct
14 Correct 0 ms 83092 KB Output is correct
15 Correct 0 ms 83092 KB Output is correct
16 Correct 0 ms 83092 KB Output is correct
17 Correct 3 ms 83092 KB Output is correct
18 Correct 0 ms 83092 KB Output is correct
19 Correct 0 ms 83092 KB Output is correct
20 Correct 6 ms 83092 KB Output is correct
21 Correct 16 ms 83092 KB Output is correct
22 Correct 29 ms 83092 KB Output is correct
23 Correct 16 ms 83092 KB Output is correct
24 Correct 59 ms 83092 KB Output is correct
25 Correct 123 ms 83092 KB Output is correct
26 Correct 156 ms 83092 KB Output is correct
27 Correct 129 ms 83092 KB Output is correct
28 Correct 133 ms 83092 KB Output is correct
29 Correct 149 ms 83092 KB Output is correct
30 Correct 73 ms 83092 KB Output is correct
31 Correct 119 ms 83092 KB Output is correct
32 Correct 66 ms 83092 KB Output is correct
33 Correct 146 ms 83092 KB Output is correct
34 Correct 149 ms 83092 KB Output is correct
35 Correct 169 ms 83092 KB Output is correct
36 Correct 69 ms 83092 KB Output is correct
37 Execution timed out 1000 ms 83232 KB Execution timed out
38 Halted 0 ms 0 KB -