/*
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
\\ //
// 271828___182845__904523__53602__ \\
\\ 87___47____13______52____66__24_ //
// 97___75____72______47____09___36 \\
\\ 999595_____74______96____69___67 //
// 62___77____24______07____66__30_ \\
\\ 35___35____47______59____45713__ //
// \\
\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
*/
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <algorithm>
#include <random>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <tuple>
#include <bitset>
#include <chrono>
#include <ctime>
#include <fstream>
#include <stack>
#include <cstdio>
using namespace std;
using ll = long long;
const int N = 3e5 + 5;
const ll mod = 1e9 + 7, inf = 1e12;
void solve() {
// start time - 1:05
int n; cin >> n;
vector<int> v(n + 1);
int sm = 0;
int mx = 0;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
sm += v[i];
mx = max(mx, v[i]);
}
map<int, int> mp;
mx = 100;
for (int ii = 0; ii <= n; ++ii) {
int cur = sm - v[ii];
vector<vector<int>> dp(n + 1, vector<int>(mx * mx + 5));
dp[0][0] = 1;
for (int i = 1; i <= n; ++i) {
dp[i] = dp[i - 1];
if (i == ii) continue;
vector<int> dp_ = dp[i];
for (int j = 0; j + v[i] <= mx * mx; ++j) {
dp_[j + v[i]] |= dp[i][j];
//if (!ii && i == 1 && j + v[i] == 1 && dp[i][j]) cout << "A\n";
}
dp[i] = dp_;
//if(!ii) cout << dp[1][1] << "\n";
// 1 3 1 5
}
for (int j = 1; j <= mx * mx; ++j) {
if (!ii && (cur % 2 || !dp[n][cur / 2])) {
//cout << dp[1][1] << "\n";
cout << "0\n";
return;
}
if (ii) {
if ((cur + j) % 2) continue;
if (dp[n][(cur + j) / 2]) ++mp[j];
}
}
}
int c = 0;
for (pair<int, int> x : mp) {
if (x.second == n) ++c;
}
cout << c << "\n";
for (pair<int, int> x : mp) {
if (x.second == n) cout << x.first << " ";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
//int t; cin >> t;
//while (t--)
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
5 |
Correct |
8 ms |
900 KB |
Output is correct |
6 |
Correct |
4 ms |
740 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
7 ms |
900 KB |
Output is correct |
9 |
Correct |
5 ms |
824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
5 |
Correct |
8 ms |
900 KB |
Output is correct |
6 |
Correct |
4 ms |
740 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
7 ms |
900 KB |
Output is correct |
9 |
Correct |
5 ms |
824 KB |
Output is correct |
10 |
Correct |
42 ms |
1652 KB |
Output is correct |
11 |
Correct |
41 ms |
1608 KB |
Output is correct |
12 |
Correct |
39 ms |
1732 KB |
Output is correct |
13 |
Correct |
33 ms |
1520 KB |
Output is correct |
14 |
Correct |
35 ms |
1528 KB |
Output is correct |
15 |
Correct |
32 ms |
1636 KB |
Output is correct |
16 |
Correct |
41 ms |
1652 KB |
Output is correct |
17 |
Correct |
16 ms |
1128 KB |
Output is correct |
18 |
Correct |
26 ms |
1364 KB |
Output is correct |
19 |
Correct |
32 ms |
1436 KB |
Output is correct |
20 |
Correct |
44 ms |
1688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
5 |
Correct |
8 ms |
900 KB |
Output is correct |
6 |
Correct |
4 ms |
740 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
7 ms |
900 KB |
Output is correct |
9 |
Correct |
5 ms |
824 KB |
Output is correct |
10 |
Correct |
42 ms |
1652 KB |
Output is correct |
11 |
Correct |
41 ms |
1608 KB |
Output is correct |
12 |
Correct |
39 ms |
1732 KB |
Output is correct |
13 |
Correct |
33 ms |
1520 KB |
Output is correct |
14 |
Correct |
35 ms |
1528 KB |
Output is correct |
15 |
Correct |
32 ms |
1636 KB |
Output is correct |
16 |
Correct |
41 ms |
1652 KB |
Output is correct |
17 |
Correct |
16 ms |
1128 KB |
Output is correct |
18 |
Correct |
26 ms |
1364 KB |
Output is correct |
19 |
Correct |
32 ms |
1436 KB |
Output is correct |
20 |
Correct |
44 ms |
1688 KB |
Output is correct |
21 |
Correct |
144 ms |
3004 KB |
Output is correct |
22 |
Correct |
197 ms |
3412 KB |
Output is correct |
23 |
Correct |
87 ms |
2428 KB |
Output is correct |
24 |
Correct |
289 ms |
4216 KB |
Output is correct |
25 |
Correct |
271 ms |
4268 KB |
Output is correct |
26 |
Correct |
375 ms |
4520 KB |
Output is correct |
27 |
Correct |
370 ms |
4416 KB |
Output is correct |
28 |
Correct |
274 ms |
4484 KB |
Output is correct |
29 |
Correct |
336 ms |
4512 KB |
Output is correct |
30 |
Correct |
327 ms |
4580 KB |
Output is correct |
31 |
Correct |
322 ms |
4504 KB |
Output is correct |
32 |
Correct |
350 ms |
4444 KB |
Output is correct |
33 |
Correct |
459 ms |
4432 KB |
Output is correct |
34 |
Correct |
424 ms |
4352 KB |
Output is correct |
35 |
Correct |
354 ms |
4480 KB |
Output is correct |
36 |
Correct |
368 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
5 |
Correct |
8 ms |
900 KB |
Output is correct |
6 |
Correct |
4 ms |
740 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
7 ms |
900 KB |
Output is correct |
9 |
Correct |
5 ms |
824 KB |
Output is correct |
10 |
Correct |
42 ms |
1652 KB |
Output is correct |
11 |
Correct |
41 ms |
1608 KB |
Output is correct |
12 |
Correct |
39 ms |
1732 KB |
Output is correct |
13 |
Correct |
33 ms |
1520 KB |
Output is correct |
14 |
Correct |
35 ms |
1528 KB |
Output is correct |
15 |
Correct |
32 ms |
1636 KB |
Output is correct |
16 |
Correct |
41 ms |
1652 KB |
Output is correct |
17 |
Correct |
16 ms |
1128 KB |
Output is correct |
18 |
Correct |
26 ms |
1364 KB |
Output is correct |
19 |
Correct |
32 ms |
1436 KB |
Output is correct |
20 |
Correct |
44 ms |
1688 KB |
Output is correct |
21 |
Correct |
144 ms |
3004 KB |
Output is correct |
22 |
Correct |
197 ms |
3412 KB |
Output is correct |
23 |
Correct |
87 ms |
2428 KB |
Output is correct |
24 |
Correct |
289 ms |
4216 KB |
Output is correct |
25 |
Correct |
271 ms |
4268 KB |
Output is correct |
26 |
Correct |
375 ms |
4520 KB |
Output is correct |
27 |
Correct |
370 ms |
4416 KB |
Output is correct |
28 |
Correct |
274 ms |
4484 KB |
Output is correct |
29 |
Correct |
336 ms |
4512 KB |
Output is correct |
30 |
Correct |
327 ms |
4580 KB |
Output is correct |
31 |
Correct |
322 ms |
4504 KB |
Output is correct |
32 |
Correct |
350 ms |
4444 KB |
Output is correct |
33 |
Correct |
459 ms |
4432 KB |
Output is correct |
34 |
Correct |
424 ms |
4352 KB |
Output is correct |
35 |
Correct |
354 ms |
4480 KB |
Output is correct |
36 |
Correct |
368 ms |
4444 KB |
Output is correct |
37 |
Execution timed out |
1076 ms |
8480 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
5 |
Correct |
8 ms |
900 KB |
Output is correct |
6 |
Correct |
4 ms |
740 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
7 ms |
900 KB |
Output is correct |
9 |
Correct |
5 ms |
824 KB |
Output is correct |
10 |
Correct |
42 ms |
1652 KB |
Output is correct |
11 |
Correct |
41 ms |
1608 KB |
Output is correct |
12 |
Correct |
39 ms |
1732 KB |
Output is correct |
13 |
Correct |
33 ms |
1520 KB |
Output is correct |
14 |
Correct |
35 ms |
1528 KB |
Output is correct |
15 |
Correct |
32 ms |
1636 KB |
Output is correct |
16 |
Correct |
41 ms |
1652 KB |
Output is correct |
17 |
Correct |
16 ms |
1128 KB |
Output is correct |
18 |
Correct |
26 ms |
1364 KB |
Output is correct |
19 |
Correct |
32 ms |
1436 KB |
Output is correct |
20 |
Correct |
44 ms |
1688 KB |
Output is correct |
21 |
Correct |
144 ms |
3004 KB |
Output is correct |
22 |
Correct |
197 ms |
3412 KB |
Output is correct |
23 |
Correct |
87 ms |
2428 KB |
Output is correct |
24 |
Correct |
289 ms |
4216 KB |
Output is correct |
25 |
Correct |
271 ms |
4268 KB |
Output is correct |
26 |
Correct |
375 ms |
4520 KB |
Output is correct |
27 |
Correct |
370 ms |
4416 KB |
Output is correct |
28 |
Correct |
274 ms |
4484 KB |
Output is correct |
29 |
Correct |
336 ms |
4512 KB |
Output is correct |
30 |
Correct |
327 ms |
4580 KB |
Output is correct |
31 |
Correct |
322 ms |
4504 KB |
Output is correct |
32 |
Correct |
350 ms |
4444 KB |
Output is correct |
33 |
Correct |
459 ms |
4432 KB |
Output is correct |
34 |
Correct |
424 ms |
4352 KB |
Output is correct |
35 |
Correct |
354 ms |
4480 KB |
Output is correct |
36 |
Correct |
368 ms |
4444 KB |
Output is correct |
37 |
Execution timed out |
1076 ms |
8480 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
5 |
Correct |
8 ms |
900 KB |
Output is correct |
6 |
Correct |
4 ms |
740 KB |
Output is correct |
7 |
Correct |
2 ms |
652 KB |
Output is correct |
8 |
Correct |
7 ms |
900 KB |
Output is correct |
9 |
Correct |
5 ms |
824 KB |
Output is correct |
10 |
Correct |
42 ms |
1652 KB |
Output is correct |
11 |
Correct |
41 ms |
1608 KB |
Output is correct |
12 |
Correct |
39 ms |
1732 KB |
Output is correct |
13 |
Correct |
33 ms |
1520 KB |
Output is correct |
14 |
Correct |
35 ms |
1528 KB |
Output is correct |
15 |
Correct |
32 ms |
1636 KB |
Output is correct |
16 |
Correct |
41 ms |
1652 KB |
Output is correct |
17 |
Correct |
16 ms |
1128 KB |
Output is correct |
18 |
Correct |
26 ms |
1364 KB |
Output is correct |
19 |
Correct |
32 ms |
1436 KB |
Output is correct |
20 |
Correct |
44 ms |
1688 KB |
Output is correct |
21 |
Correct |
144 ms |
3004 KB |
Output is correct |
22 |
Correct |
197 ms |
3412 KB |
Output is correct |
23 |
Correct |
87 ms |
2428 KB |
Output is correct |
24 |
Correct |
289 ms |
4216 KB |
Output is correct |
25 |
Correct |
271 ms |
4268 KB |
Output is correct |
26 |
Correct |
375 ms |
4520 KB |
Output is correct |
27 |
Correct |
370 ms |
4416 KB |
Output is correct |
28 |
Correct |
274 ms |
4484 KB |
Output is correct |
29 |
Correct |
336 ms |
4512 KB |
Output is correct |
30 |
Correct |
327 ms |
4580 KB |
Output is correct |
31 |
Correct |
322 ms |
4504 KB |
Output is correct |
32 |
Correct |
350 ms |
4444 KB |
Output is correct |
33 |
Correct |
459 ms |
4432 KB |
Output is correct |
34 |
Correct |
424 ms |
4352 KB |
Output is correct |
35 |
Correct |
354 ms |
4480 KB |
Output is correct |
36 |
Correct |
368 ms |
4444 KB |
Output is correct |
37 |
Execution timed out |
1076 ms |
8480 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |