#include "bits/stdc++.h"
using namespace std;
int vis[700][3000];
int poss[5000];
int sm[3000];
int a[700];
int N;
void dfs(int skip, int u = -1, int d = 0) {
if (-1 ^ u) {
vis[u][d] = skip;
}
sm[d] = 1;
for (int j = u + 1; j < N; j ++) {
if (j ^ skip && skip != vis[j][d + a[j]]) {
dfs(skip, j, d + a[j]);
}
}
}
void solve() {
cin >> N;
for (int i = 0; i < N; i ++) {
cin >> a[i];
}
memset(vis, 0x3f, sizeof(vis));
int f = 1;
for (int i = 0; i <= N; i ++) {
memset(sm, 0, sizeof(sm));
int sum = 0;
for (int j = 0; j < N; j ++) {
if (i ^ j) {
sum += a[j];
}
}
dfs(i);
if (N == i) {
f = sm[sum / 2] && !(sum & 1);
continue;
}
for (int j = 0; j < 3000; j ++) {
if (sm[j] && j * 2 > sum ) {
poss[j * 2 - sum] ++;
}
}
}
if (0 == f) {
cout << 0 << endl;
return;
}
vector<int> ans;
for (int j = 1; j < 5000; j ++) {
if (poss[j] == N) {
ans.push_back(j);
}
}
cout << ans.size() << endl;
for (int i : ans) {
cout << i << ' ';
}
cout << endl;
}
int main() {
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8700 KB |
Output is correct |
3 |
Correct |
3 ms |
8528 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
3 ms |
8528 KB |
Output is correct |
6 |
Correct |
3 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8528 KB |
Output is correct |
9 |
Correct |
3 ms |
8696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8700 KB |
Output is correct |
3 |
Correct |
3 ms |
8528 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
3 ms |
8528 KB |
Output is correct |
6 |
Correct |
3 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8528 KB |
Output is correct |
9 |
Correct |
3 ms |
8696 KB |
Output is correct |
10 |
Correct |
4 ms |
8528 KB |
Output is correct |
11 |
Correct |
5 ms |
8528 KB |
Output is correct |
12 |
Correct |
4 ms |
8528 KB |
Output is correct |
13 |
Correct |
5 ms |
8528 KB |
Output is correct |
14 |
Correct |
5 ms |
8528 KB |
Output is correct |
15 |
Correct |
4 ms |
8528 KB |
Output is correct |
16 |
Correct |
5 ms |
8696 KB |
Output is correct |
17 |
Correct |
4 ms |
8528 KB |
Output is correct |
18 |
Correct |
5 ms |
8528 KB |
Output is correct |
19 |
Correct |
4 ms |
8528 KB |
Output is correct |
20 |
Correct |
4 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8700 KB |
Output is correct |
3 |
Correct |
3 ms |
8528 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
3 ms |
8528 KB |
Output is correct |
6 |
Correct |
3 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8528 KB |
Output is correct |
9 |
Correct |
3 ms |
8696 KB |
Output is correct |
10 |
Correct |
4 ms |
8528 KB |
Output is correct |
11 |
Correct |
5 ms |
8528 KB |
Output is correct |
12 |
Correct |
4 ms |
8528 KB |
Output is correct |
13 |
Correct |
5 ms |
8528 KB |
Output is correct |
14 |
Correct |
5 ms |
8528 KB |
Output is correct |
15 |
Correct |
4 ms |
8528 KB |
Output is correct |
16 |
Correct |
5 ms |
8696 KB |
Output is correct |
17 |
Correct |
4 ms |
8528 KB |
Output is correct |
18 |
Correct |
5 ms |
8528 KB |
Output is correct |
19 |
Correct |
4 ms |
8528 KB |
Output is correct |
20 |
Correct |
4 ms |
8528 KB |
Output is correct |
21 |
Incorrect |
181 ms |
8528 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8700 KB |
Output is correct |
3 |
Correct |
3 ms |
8528 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
3 ms |
8528 KB |
Output is correct |
6 |
Correct |
3 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8528 KB |
Output is correct |
9 |
Correct |
3 ms |
8696 KB |
Output is correct |
10 |
Correct |
4 ms |
8528 KB |
Output is correct |
11 |
Correct |
5 ms |
8528 KB |
Output is correct |
12 |
Correct |
4 ms |
8528 KB |
Output is correct |
13 |
Correct |
5 ms |
8528 KB |
Output is correct |
14 |
Correct |
5 ms |
8528 KB |
Output is correct |
15 |
Correct |
4 ms |
8528 KB |
Output is correct |
16 |
Correct |
5 ms |
8696 KB |
Output is correct |
17 |
Correct |
4 ms |
8528 KB |
Output is correct |
18 |
Correct |
5 ms |
8528 KB |
Output is correct |
19 |
Correct |
4 ms |
8528 KB |
Output is correct |
20 |
Correct |
4 ms |
8528 KB |
Output is correct |
21 |
Incorrect |
181 ms |
8528 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8700 KB |
Output is correct |
3 |
Correct |
3 ms |
8528 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
3 ms |
8528 KB |
Output is correct |
6 |
Correct |
3 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8528 KB |
Output is correct |
9 |
Correct |
3 ms |
8696 KB |
Output is correct |
10 |
Correct |
4 ms |
8528 KB |
Output is correct |
11 |
Correct |
5 ms |
8528 KB |
Output is correct |
12 |
Correct |
4 ms |
8528 KB |
Output is correct |
13 |
Correct |
5 ms |
8528 KB |
Output is correct |
14 |
Correct |
5 ms |
8528 KB |
Output is correct |
15 |
Correct |
4 ms |
8528 KB |
Output is correct |
16 |
Correct |
5 ms |
8696 KB |
Output is correct |
17 |
Correct |
4 ms |
8528 KB |
Output is correct |
18 |
Correct |
5 ms |
8528 KB |
Output is correct |
19 |
Correct |
4 ms |
8528 KB |
Output is correct |
20 |
Correct |
4 ms |
8528 KB |
Output is correct |
21 |
Incorrect |
181 ms |
8528 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8528 KB |
Output is correct |
2 |
Correct |
3 ms |
8700 KB |
Output is correct |
3 |
Correct |
3 ms |
8528 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
3 ms |
8528 KB |
Output is correct |
6 |
Correct |
3 ms |
8528 KB |
Output is correct |
7 |
Correct |
3 ms |
8528 KB |
Output is correct |
8 |
Correct |
3 ms |
8528 KB |
Output is correct |
9 |
Correct |
3 ms |
8696 KB |
Output is correct |
10 |
Correct |
4 ms |
8528 KB |
Output is correct |
11 |
Correct |
5 ms |
8528 KB |
Output is correct |
12 |
Correct |
4 ms |
8528 KB |
Output is correct |
13 |
Correct |
5 ms |
8528 KB |
Output is correct |
14 |
Correct |
5 ms |
8528 KB |
Output is correct |
15 |
Correct |
4 ms |
8528 KB |
Output is correct |
16 |
Correct |
5 ms |
8696 KB |
Output is correct |
17 |
Correct |
4 ms |
8528 KB |
Output is correct |
18 |
Correct |
5 ms |
8528 KB |
Output is correct |
19 |
Correct |
4 ms |
8528 KB |
Output is correct |
20 |
Correct |
4 ms |
8528 KB |
Output is correct |
21 |
Incorrect |
181 ms |
8528 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |