/*
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
\\ //
// 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;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
sm += v[i];
}
map<int, int> mp;
for (int ii = 0; ii <= n; ++ii) {
int cur = sm - v[ii];
vector<vector<int>> dp(n + 1, vector<int>(2505));
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] <= 2500; ++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 <= 2500; ++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 << mp[3] << "\n";
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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
10 ms |
636 KB |
Output is correct |
11 |
Correct |
10 ms |
636 KB |
Output is correct |
12 |
Correct |
11 ms |
640 KB |
Output is correct |
13 |
Correct |
7 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
620 KB |
Output is correct |
15 |
Correct |
9 ms |
620 KB |
Output is correct |
16 |
Correct |
9 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
520 KB |
Output is correct |
18 |
Correct |
6 ms |
580 KB |
Output is correct |
19 |
Correct |
7 ms |
596 KB |
Output is correct |
20 |
Correct |
10 ms |
644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
10 ms |
636 KB |
Output is correct |
11 |
Correct |
10 ms |
636 KB |
Output is correct |
12 |
Correct |
11 ms |
640 KB |
Output is correct |
13 |
Correct |
7 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
620 KB |
Output is correct |
15 |
Correct |
9 ms |
620 KB |
Output is correct |
16 |
Correct |
9 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
520 KB |
Output is correct |
18 |
Correct |
6 ms |
580 KB |
Output is correct |
19 |
Correct |
7 ms |
596 KB |
Output is correct |
20 |
Correct |
10 ms |
644 KB |
Output is correct |
21 |
Incorrect |
31 ms |
960 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
10 ms |
636 KB |
Output is correct |
11 |
Correct |
10 ms |
636 KB |
Output is correct |
12 |
Correct |
11 ms |
640 KB |
Output is correct |
13 |
Correct |
7 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
620 KB |
Output is correct |
15 |
Correct |
9 ms |
620 KB |
Output is correct |
16 |
Correct |
9 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
520 KB |
Output is correct |
18 |
Correct |
6 ms |
580 KB |
Output is correct |
19 |
Correct |
7 ms |
596 KB |
Output is correct |
20 |
Correct |
10 ms |
644 KB |
Output is correct |
21 |
Incorrect |
31 ms |
960 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
10 ms |
636 KB |
Output is correct |
11 |
Correct |
10 ms |
636 KB |
Output is correct |
12 |
Correct |
11 ms |
640 KB |
Output is correct |
13 |
Correct |
7 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
620 KB |
Output is correct |
15 |
Correct |
9 ms |
620 KB |
Output is correct |
16 |
Correct |
9 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
520 KB |
Output is correct |
18 |
Correct |
6 ms |
580 KB |
Output is correct |
19 |
Correct |
7 ms |
596 KB |
Output is correct |
20 |
Correct |
10 ms |
644 KB |
Output is correct |
21 |
Incorrect |
31 ms |
960 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
10 ms |
636 KB |
Output is correct |
11 |
Correct |
10 ms |
636 KB |
Output is correct |
12 |
Correct |
11 ms |
640 KB |
Output is correct |
13 |
Correct |
7 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
620 KB |
Output is correct |
15 |
Correct |
9 ms |
620 KB |
Output is correct |
16 |
Correct |
9 ms |
744 KB |
Output is correct |
17 |
Correct |
4 ms |
520 KB |
Output is correct |
18 |
Correct |
6 ms |
580 KB |
Output is correct |
19 |
Correct |
7 ms |
596 KB |
Output is correct |
20 |
Correct |
10 ms |
644 KB |
Output is correct |
21 |
Incorrect |
31 ms |
960 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |