답안 #661102

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
661102 2022-11-24T11:52:18 Z Kaztaev_Alisher Bootfall (IZhO17_bootfall) C++17
65 / 100
197 ms 262144 KB
//#pragma GCC optomize ("Ofast")
//#pragma GCC optomize ("unroll-loops")
//#pragma GCC target ("avx,avx2,fma")

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size
#define cl clear
#define ins insert
#define ers erase
#define pii pair < int , int >
#define pll pair< long long  , long long >
#define all(x) x.begin() , x.end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define tostr(x) to_string(x)
#define tonum(s) atoi(s.c_str())
#define seon(x) setprecision(x)
#define bpop(x) __builtin_popcount(x)
#define deb(x) cerr << #x  << " = " << x << endl;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
const double PI = 3.14159265;

const ll N = 500+1, M = 500*500+1;
const ll mod = 1e9+7;
const ll inf = 1e9;
const ll INF = 1e18;

using namespace std;

int dp[N][M];
int a[N];
vector<int> ans;

void solve(){
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n ; i++) {
		cin >> a[i];
		sum += a[i];
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n ; i++) {
		for(int j = sum; j >= a[i]; j--){
			dp[0][j] += dp[0][j-a[i]];
		}
	}
	if(sum % 2 == 1 || dp[0][(sum>>1)] == 0){
		cout << 0;
		return;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= sum; j++) dp[i][j] = dp[0][j];
		for(int j = a[i]; j <= sum; j++) dp[i][j] -= dp[i][j-a[i]];
	}
	for(int i = 1; i <= sum; i++){
		int cnt = 0;
		for(int j = 1; j <= n; j++){
			int ob = sum-a[j]+i;
			if(ob % 2 == 0 && dp[j][ob/2-i]) cnt++;
		}
		if(cnt==n) ans.pb(i);
	}
	cout << ans.sz() <<"\n";
	for(int x : ans) cout << x <<" ";
}
signed main(){
	ios;
	solve();
	return 0;
}
/*
*/
 	
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 5 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4436 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 5 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 5 ms 3944 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4860 KB Output is correct
34 Correct 6 ms 4776 KB Output is correct
35 Correct 5 ms 4704 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 5 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4436 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 5 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 5 ms 3944 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4860 KB Output is correct
34 Correct 6 ms 4776 KB Output is correct
35 Correct 5 ms 4704 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 19 ms 16852 KB Output is correct
38 Correct 19 ms 17292 KB Output is correct
39 Correct 64 ms 61844 KB Output is correct
40 Correct 39 ms 36356 KB Output is correct
41 Correct 92 ms 79072 KB Output is correct
42 Correct 34 ms 31436 KB Output is correct
43 Correct 59 ms 54776 KB Output is correct
44 Correct 60 ms 56652 KB Output is correct
45 Correct 61 ms 57636 KB Output is correct
46 Correct 37 ms 35228 KB Output is correct
47 Correct 36 ms 33868 KB Output is correct
48 Correct 66 ms 62084 KB Output is correct
49 Correct 64 ms 62344 KB Output is correct
50 Correct 36 ms 33996 KB Output is correct
51 Correct 4 ms 340 KB Output is correct
52 Correct 80 ms 76348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 5 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4436 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 5 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 5 ms 3944 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4860 KB Output is correct
34 Correct 6 ms 4776 KB Output is correct
35 Correct 5 ms 4704 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 19 ms 16852 KB Output is correct
38 Correct 19 ms 17292 KB Output is correct
39 Correct 64 ms 61844 KB Output is correct
40 Correct 39 ms 36356 KB Output is correct
41 Correct 92 ms 79072 KB Output is correct
42 Correct 34 ms 31436 KB Output is correct
43 Correct 59 ms 54776 KB Output is correct
44 Correct 60 ms 56652 KB Output is correct
45 Correct 61 ms 57636 KB Output is correct
46 Correct 37 ms 35228 KB Output is correct
47 Correct 36 ms 33868 KB Output is correct
48 Correct 66 ms 62084 KB Output is correct
49 Correct 64 ms 62344 KB Output is correct
50 Correct 36 ms 33996 KB Output is correct
51 Correct 4 ms 340 KB Output is correct
52 Correct 80 ms 76348 KB Output is correct
53 Correct 58 ms 55980 KB Output is correct
54 Correct 83 ms 78840 KB Output is correct
55 Correct 156 ms 155128 KB Output is correct
56 Correct 71 ms 69188 KB Output is correct
57 Correct 164 ms 163428 KB Output is correct
58 Correct 89 ms 86476 KB Output is correct
59 Correct 111 ms 107552 KB Output is correct
60 Correct 10 ms 468 KB Output is correct
61 Correct 141 ms 120344 KB Output is correct
62 Correct 131 ms 122756 KB Output is correct
63 Correct 137 ms 132796 KB Output is correct
64 Correct 131 ms 128488 KB Output is correct
65 Correct 63 ms 61676 KB Output is correct
66 Correct 74 ms 66652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 5 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4436 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 5 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 5 ms 3944 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4860 KB Output is correct
34 Correct 6 ms 4776 KB Output is correct
35 Correct 5 ms 4704 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 19 ms 16852 KB Output is correct
38 Correct 19 ms 17292 KB Output is correct
39 Correct 64 ms 61844 KB Output is correct
40 Correct 39 ms 36356 KB Output is correct
41 Correct 92 ms 79072 KB Output is correct
42 Correct 34 ms 31436 KB Output is correct
43 Correct 59 ms 54776 KB Output is correct
44 Correct 60 ms 56652 KB Output is correct
45 Correct 61 ms 57636 KB Output is correct
46 Correct 37 ms 35228 KB Output is correct
47 Correct 36 ms 33868 KB Output is correct
48 Correct 66 ms 62084 KB Output is correct
49 Correct 64 ms 62344 KB Output is correct
50 Correct 36 ms 33996 KB Output is correct
51 Correct 4 ms 340 KB Output is correct
52 Correct 80 ms 76348 KB Output is correct
53 Correct 58 ms 55980 KB Output is correct
54 Correct 83 ms 78840 KB Output is correct
55 Correct 156 ms 155128 KB Output is correct
56 Correct 71 ms 69188 KB Output is correct
57 Correct 164 ms 163428 KB Output is correct
58 Correct 89 ms 86476 KB Output is correct
59 Correct 111 ms 107552 KB Output is correct
60 Correct 10 ms 468 KB Output is correct
61 Correct 141 ms 120344 KB Output is correct
62 Correct 131 ms 122756 KB Output is correct
63 Correct 137 ms 132796 KB Output is correct
64 Correct 131 ms 128488 KB Output is correct
65 Correct 63 ms 61676 KB Output is correct
66 Correct 74 ms 66652 KB Output is correct
67 Correct 133 ms 128492 KB Output is correct
68 Correct 29 ms 724 KB Output is correct
69 Runtime error 197 ms 262144 KB Execution killed with signal 9
70 Halted 0 ms 0 KB -