#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef long double ld;
const int MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 323456;
const ll MOD = 1000000123;
const ll MAXANS = 1000000007;
using namespace std;
int a[MAXN], ans[MAXN], dp[MAXN], d[MAXN];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
srand(time(0));
int n, i, j, sum = 0, x;
cin >> n;
dp[0] = 1;
for (i = 1; i <= n; i++){
cin >> a[i];
sum += a[i];
for (j = 250000; j >= 0; j--) (dp[j + a[i]] += dp[j]) %= MOD;
}
if (sum % 2 == 1 || dp[sum / 2] == 0) return cout << 0 << endl, 0;
for (j = 0; j <= sum; j++) d[j] = dp[j];
for (i = 1; i <= n; i++){
for (j = 0; j <= sum; j++) {
(d[j + a[i]] -= d[j] - MOD) %= MOD;
x = sum - j - a[i] - j;
if (x < 0) x *= -1;
if (d[j] != 0 && ans[x] == i - 1) ans[x] = i;
d[j] = dp[j];
}
}
vector < int > v;
for (i = 0; i <= sum; i++) if (ans[i] == n) v.p_b(i);
cout << v.size() << endl;
for (i = 0; i < v.size(); i++) cout << v[i] << " ";
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:63:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < v.size(); i++) cout << v[i] << " ";
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7232 KB |
Output is correct |
2 |
Correct |
3 ms |
7232 KB |
Output is correct |
3 |
Correct |
0 ms |
7232 KB |
Output is correct |
4 |
Correct |
3 ms |
7232 KB |
Output is correct |
5 |
Correct |
9 ms |
7232 KB |
Output is correct |
6 |
Correct |
6 ms |
7232 KB |
Output is correct |
7 |
Correct |
3 ms |
7232 KB |
Output is correct |
8 |
Correct |
13 ms |
7232 KB |
Output is correct |
9 |
Correct |
9 ms |
7232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7232 KB |
Output is correct |
2 |
Correct |
3 ms |
7232 KB |
Output is correct |
3 |
Correct |
0 ms |
7232 KB |
Output is correct |
4 |
Correct |
3 ms |
7232 KB |
Output is correct |
5 |
Correct |
9 ms |
7232 KB |
Output is correct |
6 |
Correct |
6 ms |
7232 KB |
Output is correct |
7 |
Correct |
3 ms |
7232 KB |
Output is correct |
8 |
Correct |
13 ms |
7232 KB |
Output is correct |
9 |
Correct |
9 ms |
7232 KB |
Output is correct |
10 |
Correct |
19 ms |
7232 KB |
Output is correct |
11 |
Correct |
16 ms |
7232 KB |
Output is correct |
12 |
Correct |
19 ms |
7232 KB |
Output is correct |
13 |
Correct |
19 ms |
7232 KB |
Output is correct |
14 |
Correct |
19 ms |
7232 KB |
Output is correct |
15 |
Correct |
23 ms |
7232 KB |
Output is correct |
16 |
Correct |
23 ms |
7232 KB |
Output is correct |
17 |
Correct |
13 ms |
7232 KB |
Output is correct |
18 |
Correct |
23 ms |
7232 KB |
Output is correct |
19 |
Correct |
19 ms |
7232 KB |
Output is correct |
20 |
Correct |
26 ms |
7232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7232 KB |
Output is correct |
2 |
Correct |
3 ms |
7232 KB |
Output is correct |
3 |
Correct |
0 ms |
7232 KB |
Output is correct |
4 |
Correct |
3 ms |
7232 KB |
Output is correct |
5 |
Correct |
9 ms |
7232 KB |
Output is correct |
6 |
Correct |
6 ms |
7232 KB |
Output is correct |
7 |
Correct |
3 ms |
7232 KB |
Output is correct |
8 |
Correct |
13 ms |
7232 KB |
Output is correct |
9 |
Correct |
9 ms |
7232 KB |
Output is correct |
10 |
Correct |
19 ms |
7232 KB |
Output is correct |
11 |
Correct |
16 ms |
7232 KB |
Output is correct |
12 |
Correct |
19 ms |
7232 KB |
Output is correct |
13 |
Correct |
19 ms |
7232 KB |
Output is correct |
14 |
Correct |
19 ms |
7232 KB |
Output is correct |
15 |
Correct |
23 ms |
7232 KB |
Output is correct |
16 |
Correct |
23 ms |
7232 KB |
Output is correct |
17 |
Correct |
13 ms |
7232 KB |
Output is correct |
18 |
Correct |
23 ms |
7232 KB |
Output is correct |
19 |
Correct |
19 ms |
7232 KB |
Output is correct |
20 |
Correct |
26 ms |
7232 KB |
Output is correct |
21 |
Correct |
69 ms |
7232 KB |
Output is correct |
22 |
Correct |
56 ms |
7232 KB |
Output is correct |
23 |
Correct |
39 ms |
7232 KB |
Output is correct |
24 |
Runtime error |
99 ms |
7232 KB |
Execution killed because of forbidden syscall writev (20) |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7232 KB |
Output is correct |
2 |
Correct |
3 ms |
7232 KB |
Output is correct |
3 |
Correct |
0 ms |
7232 KB |
Output is correct |
4 |
Correct |
3 ms |
7232 KB |
Output is correct |
5 |
Correct |
9 ms |
7232 KB |
Output is correct |
6 |
Correct |
6 ms |
7232 KB |
Output is correct |
7 |
Correct |
3 ms |
7232 KB |
Output is correct |
8 |
Correct |
13 ms |
7232 KB |
Output is correct |
9 |
Correct |
9 ms |
7232 KB |
Output is correct |
10 |
Correct |
19 ms |
7232 KB |
Output is correct |
11 |
Correct |
16 ms |
7232 KB |
Output is correct |
12 |
Correct |
19 ms |
7232 KB |
Output is correct |
13 |
Correct |
19 ms |
7232 KB |
Output is correct |
14 |
Correct |
19 ms |
7232 KB |
Output is correct |
15 |
Correct |
23 ms |
7232 KB |
Output is correct |
16 |
Correct |
23 ms |
7232 KB |
Output is correct |
17 |
Correct |
13 ms |
7232 KB |
Output is correct |
18 |
Correct |
23 ms |
7232 KB |
Output is correct |
19 |
Correct |
19 ms |
7232 KB |
Output is correct |
20 |
Correct |
26 ms |
7232 KB |
Output is correct |
21 |
Correct |
69 ms |
7232 KB |
Output is correct |
22 |
Correct |
56 ms |
7232 KB |
Output is correct |
23 |
Correct |
39 ms |
7232 KB |
Output is correct |
24 |
Runtime error |
99 ms |
7232 KB |
Execution killed because of forbidden syscall writev (20) |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7232 KB |
Output is correct |
2 |
Correct |
3 ms |
7232 KB |
Output is correct |
3 |
Correct |
0 ms |
7232 KB |
Output is correct |
4 |
Correct |
3 ms |
7232 KB |
Output is correct |
5 |
Correct |
9 ms |
7232 KB |
Output is correct |
6 |
Correct |
6 ms |
7232 KB |
Output is correct |
7 |
Correct |
3 ms |
7232 KB |
Output is correct |
8 |
Correct |
13 ms |
7232 KB |
Output is correct |
9 |
Correct |
9 ms |
7232 KB |
Output is correct |
10 |
Correct |
19 ms |
7232 KB |
Output is correct |
11 |
Correct |
16 ms |
7232 KB |
Output is correct |
12 |
Correct |
19 ms |
7232 KB |
Output is correct |
13 |
Correct |
19 ms |
7232 KB |
Output is correct |
14 |
Correct |
19 ms |
7232 KB |
Output is correct |
15 |
Correct |
23 ms |
7232 KB |
Output is correct |
16 |
Correct |
23 ms |
7232 KB |
Output is correct |
17 |
Correct |
13 ms |
7232 KB |
Output is correct |
18 |
Correct |
23 ms |
7232 KB |
Output is correct |
19 |
Correct |
19 ms |
7232 KB |
Output is correct |
20 |
Correct |
26 ms |
7232 KB |
Output is correct |
21 |
Correct |
69 ms |
7232 KB |
Output is correct |
22 |
Correct |
56 ms |
7232 KB |
Output is correct |
23 |
Correct |
39 ms |
7232 KB |
Output is correct |
24 |
Runtime error |
99 ms |
7232 KB |
Execution killed because of forbidden syscall writev (20) |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7232 KB |
Output is correct |
2 |
Correct |
3 ms |
7232 KB |
Output is correct |
3 |
Correct |
0 ms |
7232 KB |
Output is correct |
4 |
Correct |
3 ms |
7232 KB |
Output is correct |
5 |
Correct |
9 ms |
7232 KB |
Output is correct |
6 |
Correct |
6 ms |
7232 KB |
Output is correct |
7 |
Correct |
3 ms |
7232 KB |
Output is correct |
8 |
Correct |
13 ms |
7232 KB |
Output is correct |
9 |
Correct |
9 ms |
7232 KB |
Output is correct |
10 |
Correct |
19 ms |
7232 KB |
Output is correct |
11 |
Correct |
16 ms |
7232 KB |
Output is correct |
12 |
Correct |
19 ms |
7232 KB |
Output is correct |
13 |
Correct |
19 ms |
7232 KB |
Output is correct |
14 |
Correct |
19 ms |
7232 KB |
Output is correct |
15 |
Correct |
23 ms |
7232 KB |
Output is correct |
16 |
Correct |
23 ms |
7232 KB |
Output is correct |
17 |
Correct |
13 ms |
7232 KB |
Output is correct |
18 |
Correct |
23 ms |
7232 KB |
Output is correct |
19 |
Correct |
19 ms |
7232 KB |
Output is correct |
20 |
Correct |
26 ms |
7232 KB |
Output is correct |
21 |
Correct |
69 ms |
7232 KB |
Output is correct |
22 |
Correct |
56 ms |
7232 KB |
Output is correct |
23 |
Correct |
39 ms |
7232 KB |
Output is correct |
24 |
Runtime error |
99 ms |
7232 KB |
Execution killed because of forbidden syscall writev (20) |
25 |
Halted |
0 ms |
0 KB |
- |