#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[20005],dp[20005],sum,s,oo,x;
vector<ll>anss,v;
bool check(ll k){
v.clear();
s = 0;
for(int i=1; i<=n; i++)if(i != k)v.pb(a[i]),s += a[i];
if(s % 2 == 1)return false;
for(int i=1; i<=s; i++)dp[i] = 0;
dp[0] = 1;
for(int i=0; i<v.size(); i++){
for(int j=s; j>=0; j--){
dp[j + v[i]] = max(dp[j],dp[j + v[i]]);
}
}
return dp[s / 2];
}
int main(){
std::ios::sync_with_stdio(false);
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i];
sum += a[i];
}
n++;
for(x=1; x<=sum; x++){
a[n] = x;
oo = 0;
for(int i=1; i<=n; i++){
if(!check(i)){
oo = 1;
break;
}
}
if(!oo){
anss.pb(x);
}
}
cout << anss.size() << endl;
for(int i=0; i<anss.size(); i++)cout << anss[i] << " ";
return 0;
}
Compilation message
bootfall.cpp: In function 'bool check(int)':
bootfall.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:62:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<anss.size(); i++)cout << anss[i] << " ";
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
49 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
101 ms |
528 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
49 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
101 ms |
528 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
27 ms |
380 KB |
Output is correct |
11 |
Correct |
58 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
66 ms |
476 KB |
Output is correct |
15 |
Correct |
37 ms |
376 KB |
Output is correct |
16 |
Correct |
56 ms |
504 KB |
Output is correct |
17 |
Correct |
12 ms |
376 KB |
Output is correct |
18 |
Correct |
34 ms |
376 KB |
Output is correct |
19 |
Correct |
25 ms |
376 KB |
Output is correct |
20 |
Correct |
28 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
49 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
101 ms |
528 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
27 ms |
380 KB |
Output is correct |
11 |
Correct |
58 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
66 ms |
476 KB |
Output is correct |
15 |
Correct |
37 ms |
376 KB |
Output is correct |
16 |
Correct |
56 ms |
504 KB |
Output is correct |
17 |
Correct |
12 ms |
376 KB |
Output is correct |
18 |
Correct |
34 ms |
376 KB |
Output is correct |
19 |
Correct |
25 ms |
376 KB |
Output is correct |
20 |
Correct |
28 ms |
376 KB |
Output is correct |
21 |
Execution timed out |
1066 ms |
376 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
49 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
101 ms |
528 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
27 ms |
380 KB |
Output is correct |
11 |
Correct |
58 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
66 ms |
476 KB |
Output is correct |
15 |
Correct |
37 ms |
376 KB |
Output is correct |
16 |
Correct |
56 ms |
504 KB |
Output is correct |
17 |
Correct |
12 ms |
376 KB |
Output is correct |
18 |
Correct |
34 ms |
376 KB |
Output is correct |
19 |
Correct |
25 ms |
376 KB |
Output is correct |
20 |
Correct |
28 ms |
376 KB |
Output is correct |
21 |
Execution timed out |
1066 ms |
376 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
49 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
101 ms |
528 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
27 ms |
380 KB |
Output is correct |
11 |
Correct |
58 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
66 ms |
476 KB |
Output is correct |
15 |
Correct |
37 ms |
376 KB |
Output is correct |
16 |
Correct |
56 ms |
504 KB |
Output is correct |
17 |
Correct |
12 ms |
376 KB |
Output is correct |
18 |
Correct |
34 ms |
376 KB |
Output is correct |
19 |
Correct |
25 ms |
376 KB |
Output is correct |
20 |
Correct |
28 ms |
376 KB |
Output is correct |
21 |
Execution timed out |
1066 ms |
376 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
49 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
101 ms |
528 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
27 ms |
380 KB |
Output is correct |
11 |
Correct |
58 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
66 ms |
476 KB |
Output is correct |
15 |
Correct |
37 ms |
376 KB |
Output is correct |
16 |
Correct |
56 ms |
504 KB |
Output is correct |
17 |
Correct |
12 ms |
376 KB |
Output is correct |
18 |
Correct |
34 ms |
376 KB |
Output is correct |
19 |
Correct |
25 ms |
376 KB |
Output is correct |
20 |
Correct |
28 ms |
376 KB |
Output is correct |
21 |
Execution timed out |
1066 ms |
376 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |