#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 505;
int a[N];
int main(){
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", a+i);
// I will solve for fixed Tima's strength, it can be up to O(n^2)
int sm = accumulate(a+1, a+n+1, 0);
vector<int> A;
for(int x = 0; x <= sm; ++x){
// x => Tima's fixed strength
// Tima's strength is given, we just need to say whether game is friendly or not.
// To say that, we need to know every round is draw or not.
a[n+1] = x;
bool done = 1;
// wr;
for(int ad = 1; ad <= n+1 and done; ++ad){
// ad's person is recorder in this round
// He will not play in this round.
vector<int> v;
for(int i = 1; i <= n+1; ++i)
if(i != ad)
v.pb(a[i]);
// for(int i : v)
// printf("%d ", i);
// puts("");
int wow = accumulate(all(v), 0);
vector<bool> dp(wow+1, false);
dp[0] = 1;
for(int &to : v)
for(int i = wow; i >= to; --i)
if(dp[i-to])
dp[i] = 1;
done &= (wow%2 == 0 and dp[wow/2]);
}
if(done)
A.pb(x);
}
// wr;
printf("%d\n", (int)A.size());
for(int i : A)
printf("%d ", i);
puts("");
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
bootfall.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%d", a+i);
| ~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
46 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
96 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
46 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
96 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
28 ms |
344 KB |
Output is correct |
11 |
Correct |
51 ms |
344 KB |
Output is correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
58 ms |
348 KB |
Output is correct |
15 |
Correct |
33 ms |
344 KB |
Output is correct |
16 |
Correct |
49 ms |
412 KB |
Output is correct |
17 |
Correct |
10 ms |
348 KB |
Output is correct |
18 |
Correct |
30 ms |
348 KB |
Output is correct |
19 |
Correct |
22 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
46 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
96 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
28 ms |
344 KB |
Output is correct |
11 |
Correct |
51 ms |
344 KB |
Output is correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
58 ms |
348 KB |
Output is correct |
15 |
Correct |
33 ms |
344 KB |
Output is correct |
16 |
Correct |
49 ms |
412 KB |
Output is correct |
17 |
Correct |
10 ms |
348 KB |
Output is correct |
18 |
Correct |
30 ms |
348 KB |
Output is correct |
19 |
Correct |
22 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
440 KB |
Output is correct |
21 |
Execution timed out |
1062 ms |
412 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
46 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
96 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
28 ms |
344 KB |
Output is correct |
11 |
Correct |
51 ms |
344 KB |
Output is correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
58 ms |
348 KB |
Output is correct |
15 |
Correct |
33 ms |
344 KB |
Output is correct |
16 |
Correct |
49 ms |
412 KB |
Output is correct |
17 |
Correct |
10 ms |
348 KB |
Output is correct |
18 |
Correct |
30 ms |
348 KB |
Output is correct |
19 |
Correct |
22 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
440 KB |
Output is correct |
21 |
Execution timed out |
1062 ms |
412 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
46 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
96 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
28 ms |
344 KB |
Output is correct |
11 |
Correct |
51 ms |
344 KB |
Output is correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
58 ms |
348 KB |
Output is correct |
15 |
Correct |
33 ms |
344 KB |
Output is correct |
16 |
Correct |
49 ms |
412 KB |
Output is correct |
17 |
Correct |
10 ms |
348 KB |
Output is correct |
18 |
Correct |
30 ms |
348 KB |
Output is correct |
19 |
Correct |
22 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
440 KB |
Output is correct |
21 |
Execution timed out |
1062 ms |
412 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
46 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
96 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
28 ms |
344 KB |
Output is correct |
11 |
Correct |
51 ms |
344 KB |
Output is correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
58 ms |
348 KB |
Output is correct |
15 |
Correct |
33 ms |
344 KB |
Output is correct |
16 |
Correct |
49 ms |
412 KB |
Output is correct |
17 |
Correct |
10 ms |
348 KB |
Output is correct |
18 |
Correct |
30 ms |
348 KB |
Output is correct |
19 |
Correct |
22 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
440 KB |
Output is correct |
21 |
Execution timed out |
1062 ms |
412 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |