///////////////////////////
// INFO //
// //
// Handle -> Scayre //
// //
// Template vers. 1.1 //
// //
// It'll be accepted //
// //
///////////////////////////
//████╗████████╗██╗███████╗══███╗═══███╗████████╗════//
//═██╔╝═══██╔══╝╚█║██╔════╝══████╗═████║██╔═════╝═══//
//═██║════██║════╚╝███████╗══██╔████╔██║█████╗══════//
//═██║════██║══════╚════██║══██║╚██╔╝██║██╔══╝══════//
//████╗═══██║══════███████║══██║═╚═╝═██║███████╗═════//
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <complex>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
#define f first
#define s second
#define inf (int)1e9 + 7
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp(x,y) make_pair(x,y)
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
#define pb push_back
#define ppb pop_back
#define bitcoin __builtin_popcount
#define endl "\n"
#define in(x) insert(x)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define pw2(x) (1<<x) //2^x
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define sqr(x) ((x) * 1ll * (x))
#define UpdateRandom srand (time(NULL));
using namespace std;
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;
int n,sum;
int cnt[N];
bool u[N];
int a[N];
int dp[N];
vector<int> v,b;
int main(){
#ifdef IOI2019
freopen ("in.txt", "r", stdin);
#endif
NFS
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
sum+=a[i];
}
if(sum%2==1){
cout << 0 << endl;
ioi
}
memset(dp,-1,sizeof(dp));
dp[0]=0;
for(int i=1;i<=n;i++){
for(int j=sum/2;j>=a[i];j--){
if(dp[j-a[i]]!=-1 && dp[j]==-1){
dp[j]=i;
}
}
}
if(dp[sum/2]==-1){
cout << 0 << endl;
ioi
}
for(int k=1;k<=n;k++){
int x=a[k];
a[k]=0;
memset(u,0,sizeof(u));
memset(dp,-1,sizeof(dp));
dp[0]=0;
sum-=x;
for(int i=1;i<=n;i++){
for(int j=sum;j>=a[i];j--){
if(dp[j-a[i]]!=-1 && dp[j]==-1){
dp[j]=i;
}
}
}
//cout << k << endl;
for(int j=sum;j>=0;j--){
if(dp[j]!=-1){
if(u[abs(j-(sum-j))]!=1){
cnt[abs(j-(sum-j))]++;
}
u[abs(j-(sum-j))]=1;
}
}
//cout << endl;
a[k]=x;
sum+=x;
}
for(int i=1;i<=sum;i++){
if(cnt[i]==n){
v.pb(i);
}
}
cout << sz(v) << endl;
for(int i=0;i<sz(v);i++){
cout << v[i] << ' ';
}
#ifdef IOI2019
cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
#endif
ioi
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2996 KB |
Output is correct |
3 |
Correct |
4 ms |
2996 KB |
Output is correct |
4 |
Correct |
4 ms |
2996 KB |
Output is correct |
5 |
Correct |
6 ms |
2996 KB |
Output is correct |
6 |
Correct |
5 ms |
2996 KB |
Output is correct |
7 |
Correct |
5 ms |
2996 KB |
Output is correct |
8 |
Correct |
7 ms |
2996 KB |
Output is correct |
9 |
Correct |
7 ms |
2996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2996 KB |
Output is correct |
3 |
Correct |
4 ms |
2996 KB |
Output is correct |
4 |
Correct |
4 ms |
2996 KB |
Output is correct |
5 |
Correct |
6 ms |
2996 KB |
Output is correct |
6 |
Correct |
5 ms |
2996 KB |
Output is correct |
7 |
Correct |
5 ms |
2996 KB |
Output is correct |
8 |
Correct |
7 ms |
2996 KB |
Output is correct |
9 |
Correct |
7 ms |
2996 KB |
Output is correct |
10 |
Correct |
8 ms |
2996 KB |
Output is correct |
11 |
Correct |
8 ms |
2996 KB |
Output is correct |
12 |
Correct |
9 ms |
3032 KB |
Output is correct |
13 |
Correct |
7 ms |
3032 KB |
Output is correct |
14 |
Correct |
8 ms |
3080 KB |
Output is correct |
15 |
Correct |
7 ms |
3096 KB |
Output is correct |
16 |
Correct |
8 ms |
3100 KB |
Output is correct |
17 |
Correct |
6 ms |
3104 KB |
Output is correct |
18 |
Correct |
7 ms |
3108 KB |
Output is correct |
19 |
Correct |
7 ms |
3112 KB |
Output is correct |
20 |
Correct |
8 ms |
3116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2996 KB |
Output is correct |
3 |
Correct |
4 ms |
2996 KB |
Output is correct |
4 |
Correct |
4 ms |
2996 KB |
Output is correct |
5 |
Correct |
6 ms |
2996 KB |
Output is correct |
6 |
Correct |
5 ms |
2996 KB |
Output is correct |
7 |
Correct |
5 ms |
2996 KB |
Output is correct |
8 |
Correct |
7 ms |
2996 KB |
Output is correct |
9 |
Correct |
7 ms |
2996 KB |
Output is correct |
10 |
Correct |
8 ms |
2996 KB |
Output is correct |
11 |
Correct |
8 ms |
2996 KB |
Output is correct |
12 |
Correct |
9 ms |
3032 KB |
Output is correct |
13 |
Correct |
7 ms |
3032 KB |
Output is correct |
14 |
Correct |
8 ms |
3080 KB |
Output is correct |
15 |
Correct |
7 ms |
3096 KB |
Output is correct |
16 |
Correct |
8 ms |
3100 KB |
Output is correct |
17 |
Correct |
6 ms |
3104 KB |
Output is correct |
18 |
Correct |
7 ms |
3108 KB |
Output is correct |
19 |
Correct |
7 ms |
3112 KB |
Output is correct |
20 |
Correct |
8 ms |
3116 KB |
Output is correct |
21 |
Correct |
26 ms |
3120 KB |
Output is correct |
22 |
Correct |
40 ms |
3124 KB |
Output is correct |
23 |
Correct |
18 ms |
3148 KB |
Output is correct |
24 |
Correct |
61 ms |
3276 KB |
Output is correct |
25 |
Correct |
205 ms |
3276 KB |
Output is correct |
26 |
Correct |
213 ms |
3360 KB |
Output is correct |
27 |
Correct |
278 ms |
3360 KB |
Output is correct |
28 |
Correct |
251 ms |
3360 KB |
Output is correct |
29 |
Correct |
240 ms |
3360 KB |
Output is correct |
30 |
Correct |
67 ms |
3360 KB |
Output is correct |
31 |
Correct |
99 ms |
3360 KB |
Output is correct |
32 |
Correct |
62 ms |
3360 KB |
Output is correct |
33 |
Correct |
115 ms |
3360 KB |
Output is correct |
34 |
Correct |
130 ms |
3360 KB |
Output is correct |
35 |
Correct |
238 ms |
3360 KB |
Output is correct |
36 |
Correct |
62 ms |
3360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2996 KB |
Output is correct |
3 |
Correct |
4 ms |
2996 KB |
Output is correct |
4 |
Correct |
4 ms |
2996 KB |
Output is correct |
5 |
Correct |
6 ms |
2996 KB |
Output is correct |
6 |
Correct |
5 ms |
2996 KB |
Output is correct |
7 |
Correct |
5 ms |
2996 KB |
Output is correct |
8 |
Correct |
7 ms |
2996 KB |
Output is correct |
9 |
Correct |
7 ms |
2996 KB |
Output is correct |
10 |
Correct |
8 ms |
2996 KB |
Output is correct |
11 |
Correct |
8 ms |
2996 KB |
Output is correct |
12 |
Correct |
9 ms |
3032 KB |
Output is correct |
13 |
Correct |
7 ms |
3032 KB |
Output is correct |
14 |
Correct |
8 ms |
3080 KB |
Output is correct |
15 |
Correct |
7 ms |
3096 KB |
Output is correct |
16 |
Correct |
8 ms |
3100 KB |
Output is correct |
17 |
Correct |
6 ms |
3104 KB |
Output is correct |
18 |
Correct |
7 ms |
3108 KB |
Output is correct |
19 |
Correct |
7 ms |
3112 KB |
Output is correct |
20 |
Correct |
8 ms |
3116 KB |
Output is correct |
21 |
Correct |
26 ms |
3120 KB |
Output is correct |
22 |
Correct |
40 ms |
3124 KB |
Output is correct |
23 |
Correct |
18 ms |
3148 KB |
Output is correct |
24 |
Correct |
61 ms |
3276 KB |
Output is correct |
25 |
Correct |
205 ms |
3276 KB |
Output is correct |
26 |
Correct |
213 ms |
3360 KB |
Output is correct |
27 |
Correct |
278 ms |
3360 KB |
Output is correct |
28 |
Correct |
251 ms |
3360 KB |
Output is correct |
29 |
Correct |
240 ms |
3360 KB |
Output is correct |
30 |
Correct |
67 ms |
3360 KB |
Output is correct |
31 |
Correct |
99 ms |
3360 KB |
Output is correct |
32 |
Correct |
62 ms |
3360 KB |
Output is correct |
33 |
Correct |
115 ms |
3360 KB |
Output is correct |
34 |
Correct |
130 ms |
3360 KB |
Output is correct |
35 |
Correct |
238 ms |
3360 KB |
Output is correct |
36 |
Correct |
62 ms |
3360 KB |
Output is correct |
37 |
Correct |
777 ms |
3500 KB |
Output is correct |
38 |
Correct |
820 ms |
3500 KB |
Output is correct |
39 |
Execution timed out |
1066 ms |
3500 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2996 KB |
Output is correct |
3 |
Correct |
4 ms |
2996 KB |
Output is correct |
4 |
Correct |
4 ms |
2996 KB |
Output is correct |
5 |
Correct |
6 ms |
2996 KB |
Output is correct |
6 |
Correct |
5 ms |
2996 KB |
Output is correct |
7 |
Correct |
5 ms |
2996 KB |
Output is correct |
8 |
Correct |
7 ms |
2996 KB |
Output is correct |
9 |
Correct |
7 ms |
2996 KB |
Output is correct |
10 |
Correct |
8 ms |
2996 KB |
Output is correct |
11 |
Correct |
8 ms |
2996 KB |
Output is correct |
12 |
Correct |
9 ms |
3032 KB |
Output is correct |
13 |
Correct |
7 ms |
3032 KB |
Output is correct |
14 |
Correct |
8 ms |
3080 KB |
Output is correct |
15 |
Correct |
7 ms |
3096 KB |
Output is correct |
16 |
Correct |
8 ms |
3100 KB |
Output is correct |
17 |
Correct |
6 ms |
3104 KB |
Output is correct |
18 |
Correct |
7 ms |
3108 KB |
Output is correct |
19 |
Correct |
7 ms |
3112 KB |
Output is correct |
20 |
Correct |
8 ms |
3116 KB |
Output is correct |
21 |
Correct |
26 ms |
3120 KB |
Output is correct |
22 |
Correct |
40 ms |
3124 KB |
Output is correct |
23 |
Correct |
18 ms |
3148 KB |
Output is correct |
24 |
Correct |
61 ms |
3276 KB |
Output is correct |
25 |
Correct |
205 ms |
3276 KB |
Output is correct |
26 |
Correct |
213 ms |
3360 KB |
Output is correct |
27 |
Correct |
278 ms |
3360 KB |
Output is correct |
28 |
Correct |
251 ms |
3360 KB |
Output is correct |
29 |
Correct |
240 ms |
3360 KB |
Output is correct |
30 |
Correct |
67 ms |
3360 KB |
Output is correct |
31 |
Correct |
99 ms |
3360 KB |
Output is correct |
32 |
Correct |
62 ms |
3360 KB |
Output is correct |
33 |
Correct |
115 ms |
3360 KB |
Output is correct |
34 |
Correct |
130 ms |
3360 KB |
Output is correct |
35 |
Correct |
238 ms |
3360 KB |
Output is correct |
36 |
Correct |
62 ms |
3360 KB |
Output is correct |
37 |
Correct |
777 ms |
3500 KB |
Output is correct |
38 |
Correct |
820 ms |
3500 KB |
Output is correct |
39 |
Execution timed out |
1066 ms |
3500 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2808 KB |
Output is correct |
2 |
Correct |
5 ms |
2996 KB |
Output is correct |
3 |
Correct |
4 ms |
2996 KB |
Output is correct |
4 |
Correct |
4 ms |
2996 KB |
Output is correct |
5 |
Correct |
6 ms |
2996 KB |
Output is correct |
6 |
Correct |
5 ms |
2996 KB |
Output is correct |
7 |
Correct |
5 ms |
2996 KB |
Output is correct |
8 |
Correct |
7 ms |
2996 KB |
Output is correct |
9 |
Correct |
7 ms |
2996 KB |
Output is correct |
10 |
Correct |
8 ms |
2996 KB |
Output is correct |
11 |
Correct |
8 ms |
2996 KB |
Output is correct |
12 |
Correct |
9 ms |
3032 KB |
Output is correct |
13 |
Correct |
7 ms |
3032 KB |
Output is correct |
14 |
Correct |
8 ms |
3080 KB |
Output is correct |
15 |
Correct |
7 ms |
3096 KB |
Output is correct |
16 |
Correct |
8 ms |
3100 KB |
Output is correct |
17 |
Correct |
6 ms |
3104 KB |
Output is correct |
18 |
Correct |
7 ms |
3108 KB |
Output is correct |
19 |
Correct |
7 ms |
3112 KB |
Output is correct |
20 |
Correct |
8 ms |
3116 KB |
Output is correct |
21 |
Correct |
26 ms |
3120 KB |
Output is correct |
22 |
Correct |
40 ms |
3124 KB |
Output is correct |
23 |
Correct |
18 ms |
3148 KB |
Output is correct |
24 |
Correct |
61 ms |
3276 KB |
Output is correct |
25 |
Correct |
205 ms |
3276 KB |
Output is correct |
26 |
Correct |
213 ms |
3360 KB |
Output is correct |
27 |
Correct |
278 ms |
3360 KB |
Output is correct |
28 |
Correct |
251 ms |
3360 KB |
Output is correct |
29 |
Correct |
240 ms |
3360 KB |
Output is correct |
30 |
Correct |
67 ms |
3360 KB |
Output is correct |
31 |
Correct |
99 ms |
3360 KB |
Output is correct |
32 |
Correct |
62 ms |
3360 KB |
Output is correct |
33 |
Correct |
115 ms |
3360 KB |
Output is correct |
34 |
Correct |
130 ms |
3360 KB |
Output is correct |
35 |
Correct |
238 ms |
3360 KB |
Output is correct |
36 |
Correct |
62 ms |
3360 KB |
Output is correct |
37 |
Correct |
777 ms |
3500 KB |
Output is correct |
38 |
Correct |
820 ms |
3500 KB |
Output is correct |
39 |
Execution timed out |
1066 ms |
3500 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |