#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
const int N = 1e6 + 1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567];
bool used[1234567];
//ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//vector<ll> edge[1234567];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll power(ll base, ll val, ll mod) {
ll res = 1;
while (val) {
if (val % 2 == 1) {
res = res * base;
}
base = base * base;
base %= mod;
res %= mod;
val /= 2;
}
return res;
}
bool comp(pl x,pl y){
if(x.ff>y.ff)return true;
return false;
}
ll find(ll x){
if(x==par[x])return x;
else return par[x]=find(par[x]);
}
class A {
public:
static void funcA() {
cin>>n;
ll dp[123456];
dp[0]=1;
for(int i=1;i<=n;i++){
cin>>arr[i];
sum+=arr[i];
}
for(int i=1;i<=n;i++){
for(int j=sum;j>=0;j--){
if(j-arr[i]>=0){
dp[j] += dp[j-arr[i]];
}
}
}
bool ok[123456]={0};
for(int i=1;i<=n;i++){
for(int j=arr[i];j<=sum;j++){
dp[j] -= dp[j-arr[i]];
}
for(int j=1;j<=sum;j++){
ll k = sum - arr[i] + j;
if(k%2==1 || dp[k/2]==0){
ok[j]=1;
}
}
for(int j=sum;j>=arr[i];j--){
dp[j] += dp[j-arr[i]];
}
}
vl vec;
for(int i=1;i<=sum;i++){
if(ok[i]==0)vec.pb(i);
}
if(sum%2==1 || dp[sum/2]==0)vec.clear();
cout<<vec.size()<<'\n';
for(auto u:vec){
cout<<u<<' ';
}
}
}lol;
void solve() {
A::funcA();
}
int main() {
ll T = 1;
//cin>>T;
boost;
while (T--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1380 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1380 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1384 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1380 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1380 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1388 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
1 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1380 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1384 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1380 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1380 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1388 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
1 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
21 |
Correct |
2 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1356 KB |
Output is correct |
23 |
Correct |
2 ms |
1356 KB |
Output is correct |
24 |
Correct |
2 ms |
1356 KB |
Output is correct |
25 |
Correct |
3 ms |
1356 KB |
Output is correct |
26 |
Correct |
4 ms |
1360 KB |
Output is correct |
27 |
Correct |
5 ms |
1360 KB |
Output is correct |
28 |
Correct |
4 ms |
1360 KB |
Output is correct |
29 |
Correct |
5 ms |
1440 KB |
Output is correct |
30 |
Correct |
9 ms |
1384 KB |
Output is correct |
31 |
Correct |
4 ms |
1360 KB |
Output is correct |
32 |
Correct |
4 ms |
1360 KB |
Output is correct |
33 |
Correct |
4 ms |
1384 KB |
Output is correct |
34 |
Correct |
3 ms |
1316 KB |
Output is correct |
35 |
Correct |
4 ms |
1388 KB |
Output is correct |
36 |
Correct |
3 ms |
1360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1380 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1384 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1380 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1380 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1388 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
1 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
21 |
Correct |
2 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1356 KB |
Output is correct |
23 |
Correct |
2 ms |
1356 KB |
Output is correct |
24 |
Correct |
2 ms |
1356 KB |
Output is correct |
25 |
Correct |
3 ms |
1356 KB |
Output is correct |
26 |
Correct |
4 ms |
1360 KB |
Output is correct |
27 |
Correct |
5 ms |
1360 KB |
Output is correct |
28 |
Correct |
4 ms |
1360 KB |
Output is correct |
29 |
Correct |
5 ms |
1440 KB |
Output is correct |
30 |
Correct |
9 ms |
1384 KB |
Output is correct |
31 |
Correct |
4 ms |
1360 KB |
Output is correct |
32 |
Correct |
4 ms |
1360 KB |
Output is correct |
33 |
Correct |
4 ms |
1384 KB |
Output is correct |
34 |
Correct |
3 ms |
1316 KB |
Output is correct |
35 |
Correct |
4 ms |
1388 KB |
Output is correct |
36 |
Correct |
3 ms |
1360 KB |
Output is correct |
37 |
Correct |
13 ms |
1616 KB |
Output is correct |
38 |
Correct |
15 ms |
1656 KB |
Output is correct |
39 |
Correct |
44 ms |
1360 KB |
Output is correct |
40 |
Correct |
29 ms |
1616 KB |
Output is correct |
41 |
Correct |
58 ms |
1380 KB |
Output is correct |
42 |
Correct |
28 ms |
1648 KB |
Output is correct |
43 |
Correct |
41 ms |
1860 KB |
Output is correct |
44 |
Correct |
44 ms |
1772 KB |
Output is correct |
45 |
Correct |
46 ms |
1764 KB |
Output is correct |
46 |
Correct |
26 ms |
1360 KB |
Output is correct |
47 |
Correct |
28 ms |
1692 KB |
Output is correct |
48 |
Correct |
47 ms |
1776 KB |
Output is correct |
49 |
Correct |
45 ms |
1480 KB |
Output is correct |
50 |
Correct |
26 ms |
1744 KB |
Output is correct |
51 |
Correct |
23 ms |
1388 KB |
Output is correct |
52 |
Correct |
56 ms |
1896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1380 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1384 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1380 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1380 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1388 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
1 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
21 |
Correct |
2 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1356 KB |
Output is correct |
23 |
Correct |
2 ms |
1356 KB |
Output is correct |
24 |
Correct |
2 ms |
1356 KB |
Output is correct |
25 |
Correct |
3 ms |
1356 KB |
Output is correct |
26 |
Correct |
4 ms |
1360 KB |
Output is correct |
27 |
Correct |
5 ms |
1360 KB |
Output is correct |
28 |
Correct |
4 ms |
1360 KB |
Output is correct |
29 |
Correct |
5 ms |
1440 KB |
Output is correct |
30 |
Correct |
9 ms |
1384 KB |
Output is correct |
31 |
Correct |
4 ms |
1360 KB |
Output is correct |
32 |
Correct |
4 ms |
1360 KB |
Output is correct |
33 |
Correct |
4 ms |
1384 KB |
Output is correct |
34 |
Correct |
3 ms |
1316 KB |
Output is correct |
35 |
Correct |
4 ms |
1388 KB |
Output is correct |
36 |
Correct |
3 ms |
1360 KB |
Output is correct |
37 |
Correct |
13 ms |
1616 KB |
Output is correct |
38 |
Correct |
15 ms |
1656 KB |
Output is correct |
39 |
Correct |
44 ms |
1360 KB |
Output is correct |
40 |
Correct |
29 ms |
1616 KB |
Output is correct |
41 |
Correct |
58 ms |
1380 KB |
Output is correct |
42 |
Correct |
28 ms |
1648 KB |
Output is correct |
43 |
Correct |
41 ms |
1860 KB |
Output is correct |
44 |
Correct |
44 ms |
1772 KB |
Output is correct |
45 |
Correct |
46 ms |
1764 KB |
Output is correct |
46 |
Correct |
26 ms |
1360 KB |
Output is correct |
47 |
Correct |
28 ms |
1692 KB |
Output is correct |
48 |
Correct |
47 ms |
1776 KB |
Output is correct |
49 |
Correct |
45 ms |
1480 KB |
Output is correct |
50 |
Correct |
26 ms |
1744 KB |
Output is correct |
51 |
Correct |
23 ms |
1388 KB |
Output is correct |
52 |
Correct |
56 ms |
1896 KB |
Output is correct |
53 |
Correct |
41 ms |
1736 KB |
Output is correct |
54 |
Correct |
59 ms |
1860 KB |
Output is correct |
55 |
Correct |
117 ms |
2156 KB |
Output is correct |
56 |
Correct |
51 ms |
1884 KB |
Output is correct |
57 |
Correct |
120 ms |
2240 KB |
Output is correct |
58 |
Correct |
66 ms |
1884 KB |
Output is correct |
59 |
Correct |
79 ms |
1992 KB |
Output is correct |
60 |
Correct |
63 ms |
1360 KB |
Output is correct |
61 |
Correct |
90 ms |
2012 KB |
Output is correct |
62 |
Correct |
91 ms |
2156 KB |
Output is correct |
63 |
Correct |
100 ms |
2148 KB |
Output is correct |
64 |
Correct |
97 ms |
2132 KB |
Output is correct |
65 |
Correct |
47 ms |
1360 KB |
Output is correct |
66 |
Correct |
49 ms |
1392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1380 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1384 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1380 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1380 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1388 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
1 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
21 |
Correct |
2 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1356 KB |
Output is correct |
23 |
Correct |
2 ms |
1356 KB |
Output is correct |
24 |
Correct |
2 ms |
1356 KB |
Output is correct |
25 |
Correct |
3 ms |
1356 KB |
Output is correct |
26 |
Correct |
4 ms |
1360 KB |
Output is correct |
27 |
Correct |
5 ms |
1360 KB |
Output is correct |
28 |
Correct |
4 ms |
1360 KB |
Output is correct |
29 |
Correct |
5 ms |
1440 KB |
Output is correct |
30 |
Correct |
9 ms |
1384 KB |
Output is correct |
31 |
Correct |
4 ms |
1360 KB |
Output is correct |
32 |
Correct |
4 ms |
1360 KB |
Output is correct |
33 |
Correct |
4 ms |
1384 KB |
Output is correct |
34 |
Correct |
3 ms |
1316 KB |
Output is correct |
35 |
Correct |
4 ms |
1388 KB |
Output is correct |
36 |
Correct |
3 ms |
1360 KB |
Output is correct |
37 |
Correct |
13 ms |
1616 KB |
Output is correct |
38 |
Correct |
15 ms |
1656 KB |
Output is correct |
39 |
Correct |
44 ms |
1360 KB |
Output is correct |
40 |
Correct |
29 ms |
1616 KB |
Output is correct |
41 |
Correct |
58 ms |
1380 KB |
Output is correct |
42 |
Correct |
28 ms |
1648 KB |
Output is correct |
43 |
Correct |
41 ms |
1860 KB |
Output is correct |
44 |
Correct |
44 ms |
1772 KB |
Output is correct |
45 |
Correct |
46 ms |
1764 KB |
Output is correct |
46 |
Correct |
26 ms |
1360 KB |
Output is correct |
47 |
Correct |
28 ms |
1692 KB |
Output is correct |
48 |
Correct |
47 ms |
1776 KB |
Output is correct |
49 |
Correct |
45 ms |
1480 KB |
Output is correct |
50 |
Correct |
26 ms |
1744 KB |
Output is correct |
51 |
Correct |
23 ms |
1388 KB |
Output is correct |
52 |
Correct |
56 ms |
1896 KB |
Output is correct |
53 |
Correct |
41 ms |
1736 KB |
Output is correct |
54 |
Correct |
59 ms |
1860 KB |
Output is correct |
55 |
Correct |
117 ms |
2156 KB |
Output is correct |
56 |
Correct |
51 ms |
1884 KB |
Output is correct |
57 |
Correct |
120 ms |
2240 KB |
Output is correct |
58 |
Correct |
66 ms |
1884 KB |
Output is correct |
59 |
Correct |
79 ms |
1992 KB |
Output is correct |
60 |
Correct |
63 ms |
1360 KB |
Output is correct |
61 |
Correct |
90 ms |
2012 KB |
Output is correct |
62 |
Correct |
91 ms |
2156 KB |
Output is correct |
63 |
Correct |
100 ms |
2148 KB |
Output is correct |
64 |
Correct |
97 ms |
2132 KB |
Output is correct |
65 |
Correct |
47 ms |
1360 KB |
Output is correct |
66 |
Correct |
49 ms |
1392 KB |
Output is correct |
67 |
Correct |
96 ms |
2024 KB |
Output is correct |
68 |
Correct |
182 ms |
1376 KB |
Output is correct |
69 |
Runtime error |
3 ms |
2640 KB |
Execution killed with signal 11 |
70 |
Halted |
0 ms |
0 KB |
- |