/** kutbilim.one **/
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
/*
ifstream in("test.txt");
#define cin in */
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
vector<int> a(n);
int sum = 0;
for(int i = 0; i < n; i++)
cin >> a[i], sum += a[i];
sort(all(a));
map<int, set<int>> cnt;
int MAX = sum;
vector<int> dp(MAX+1);
dp[0] = 1;
for(int k = 0; k < n; k++){
for(int x = MAX-a[k]; x >= 0; x--){
dp[x+a[k]] |= dp[x];
}
}
int good = false;
for(int left = 0, right; left <= MAX; left++){
if(!dp[left]) continue;
right = MAX-left;
if(left == right) good = true;
}
if(!good) goto breaker;
for(int ex = 0; ex < n; ex++){
MAX = sum-a[ex];
vector<int> pd(MAX+1);
pd[0] = 1;
for(int k = 0; k < n; k++){
if(k == ex) continue;
for(int x = MAX-a[k]; x >= 0; x--){
pd[x+a[k]] |= pd[x];
}
}
for(int left = 1, right; left <= MAX; left++){
if(!pd[left]) continue;
right = MAX-left;
cnt[abs(left-right)].insert(ex);
}
}
breaker:;
stringstream resultOut;
int sizeOut = 0;
for(auto i : cnt){
if(i.second.size() == n)
resultOut << i.first << " ", sizeOut++;
}
cout << sizeOut << endl << resultOut.str();
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:65:22: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
65 | if(i.second.size() == n)
| ~~~~~~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
2 ms |
492 KB |
Output is correct |
13 |
Correct |
2 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
492 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
2 ms |
492 KB |
Output is correct |
13 |
Correct |
2 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
492 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
2 ms |
364 KB |
Output is correct |
21 |
Correct |
71 ms |
5228 KB |
Output is correct |
22 |
Correct |
92 ms |
6380 KB |
Output is correct |
23 |
Correct |
34 ms |
3180 KB |
Output is correct |
24 |
Correct |
184 ms |
10752 KB |
Output is correct |
25 |
Correct |
352 ms |
16492 KB |
Output is correct |
26 |
Correct |
409 ms |
18720 KB |
Output is correct |
27 |
Correct |
344 ms |
10092 KB |
Output is correct |
28 |
Correct |
344 ms |
9352 KB |
Output is correct |
29 |
Correct |
373 ms |
11648 KB |
Output is correct |
30 |
Correct |
235 ms |
13164 KB |
Output is correct |
31 |
Correct |
335 ms |
17900 KB |
Output is correct |
32 |
Correct |
205 ms |
11936 KB |
Output is correct |
33 |
Correct |
319 ms |
876 KB |
Output is correct |
34 |
Correct |
314 ms |
868 KB |
Output is correct |
35 |
Correct |
366 ms |
9964 KB |
Output is correct |
36 |
Correct |
204 ms |
11500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
2 ms |
492 KB |
Output is correct |
13 |
Correct |
2 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
492 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
2 ms |
364 KB |
Output is correct |
21 |
Correct |
71 ms |
5228 KB |
Output is correct |
22 |
Correct |
92 ms |
6380 KB |
Output is correct |
23 |
Correct |
34 ms |
3180 KB |
Output is correct |
24 |
Correct |
184 ms |
10752 KB |
Output is correct |
25 |
Correct |
352 ms |
16492 KB |
Output is correct |
26 |
Correct |
409 ms |
18720 KB |
Output is correct |
27 |
Correct |
344 ms |
10092 KB |
Output is correct |
28 |
Correct |
344 ms |
9352 KB |
Output is correct |
29 |
Correct |
373 ms |
11648 KB |
Output is correct |
30 |
Correct |
235 ms |
13164 KB |
Output is correct |
31 |
Correct |
335 ms |
17900 KB |
Output is correct |
32 |
Correct |
205 ms |
11936 KB |
Output is correct |
33 |
Correct |
319 ms |
876 KB |
Output is correct |
34 |
Correct |
314 ms |
868 KB |
Output is correct |
35 |
Correct |
366 ms |
9964 KB |
Output is correct |
36 |
Correct |
204 ms |
11500 KB |
Output is correct |
37 |
Execution timed out |
1092 ms |
34132 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
2 ms |
492 KB |
Output is correct |
13 |
Correct |
2 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
492 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
2 ms |
364 KB |
Output is correct |
21 |
Correct |
71 ms |
5228 KB |
Output is correct |
22 |
Correct |
92 ms |
6380 KB |
Output is correct |
23 |
Correct |
34 ms |
3180 KB |
Output is correct |
24 |
Correct |
184 ms |
10752 KB |
Output is correct |
25 |
Correct |
352 ms |
16492 KB |
Output is correct |
26 |
Correct |
409 ms |
18720 KB |
Output is correct |
27 |
Correct |
344 ms |
10092 KB |
Output is correct |
28 |
Correct |
344 ms |
9352 KB |
Output is correct |
29 |
Correct |
373 ms |
11648 KB |
Output is correct |
30 |
Correct |
235 ms |
13164 KB |
Output is correct |
31 |
Correct |
335 ms |
17900 KB |
Output is correct |
32 |
Correct |
205 ms |
11936 KB |
Output is correct |
33 |
Correct |
319 ms |
876 KB |
Output is correct |
34 |
Correct |
314 ms |
868 KB |
Output is correct |
35 |
Correct |
366 ms |
9964 KB |
Output is correct |
36 |
Correct |
204 ms |
11500 KB |
Output is correct |
37 |
Execution timed out |
1092 ms |
34132 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
2 ms |
492 KB |
Output is correct |
13 |
Correct |
2 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
492 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
2 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
2 ms |
364 KB |
Output is correct |
21 |
Correct |
71 ms |
5228 KB |
Output is correct |
22 |
Correct |
92 ms |
6380 KB |
Output is correct |
23 |
Correct |
34 ms |
3180 KB |
Output is correct |
24 |
Correct |
184 ms |
10752 KB |
Output is correct |
25 |
Correct |
352 ms |
16492 KB |
Output is correct |
26 |
Correct |
409 ms |
18720 KB |
Output is correct |
27 |
Correct |
344 ms |
10092 KB |
Output is correct |
28 |
Correct |
344 ms |
9352 KB |
Output is correct |
29 |
Correct |
373 ms |
11648 KB |
Output is correct |
30 |
Correct |
235 ms |
13164 KB |
Output is correct |
31 |
Correct |
335 ms |
17900 KB |
Output is correct |
32 |
Correct |
205 ms |
11936 KB |
Output is correct |
33 |
Correct |
319 ms |
876 KB |
Output is correct |
34 |
Correct |
314 ms |
868 KB |
Output is correct |
35 |
Correct |
366 ms |
9964 KB |
Output is correct |
36 |
Correct |
204 ms |
11500 KB |
Output is correct |
37 |
Execution timed out |
1092 ms |
34132 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |