답안 #661100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
661100 2022-11-24T11:50:52 Z Kaztaev_Alisher Bootfall (IZhO17_bootfall) C++17
65 / 100
208 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+9 , M = 308000;
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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 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 1 ms 468 KB Output is correct
13 Correct 0 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 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 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 1 ms 468 KB Output is correct
13 Correct 0 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 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 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 2644 KB Output is correct
25 Correct 7 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4456 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 5 ms 4792 KB Output is correct
30 Correct 3 ms 3028 KB Output is correct
31 Correct 5 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4820 KB Output is correct
34 Correct 5 ms 4876 KB Output is correct
35 Correct 5 ms 4692 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 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 1 ms 468 KB Output is correct
13 Correct 0 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 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 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 2644 KB Output is correct
25 Correct 7 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4456 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 5 ms 4792 KB Output is correct
30 Correct 3 ms 3028 KB Output is correct
31 Correct 5 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4820 KB Output is correct
34 Correct 5 ms 4876 KB Output is correct
35 Correct 5 ms 4692 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 20 ms 16904 KB Output is correct
38 Correct 22 ms 17372 KB Output is correct
39 Correct 62 ms 61908 KB Output is correct
40 Correct 40 ms 36532 KB Output is correct
41 Correct 85 ms 79232 KB Output is correct
42 Correct 33 ms 31564 KB Output is correct
43 Correct 58 ms 54856 KB Output is correct
44 Correct 65 ms 56844 KB Output is correct
45 Correct 68 ms 57684 KB Output is correct
46 Correct 37 ms 35276 KB Output is correct
47 Correct 37 ms 33992 KB Output is correct
48 Correct 64 ms 62288 KB Output is correct
49 Correct 72 ms 62372 KB Output is correct
50 Correct 50 ms 34116 KB Output is correct
51 Correct 6 ms 452 KB Output is correct
52 Correct 82 ms 76364 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 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 1 ms 468 KB Output is correct
13 Correct 0 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 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 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 2644 KB Output is correct
25 Correct 7 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4456 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 5 ms 4792 KB Output is correct
30 Correct 3 ms 3028 KB Output is correct
31 Correct 5 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4820 KB Output is correct
34 Correct 5 ms 4876 KB Output is correct
35 Correct 5 ms 4692 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 20 ms 16904 KB Output is correct
38 Correct 22 ms 17372 KB Output is correct
39 Correct 62 ms 61908 KB Output is correct
40 Correct 40 ms 36532 KB Output is correct
41 Correct 85 ms 79232 KB Output is correct
42 Correct 33 ms 31564 KB Output is correct
43 Correct 58 ms 54856 KB Output is correct
44 Correct 65 ms 56844 KB Output is correct
45 Correct 68 ms 57684 KB Output is correct
46 Correct 37 ms 35276 KB Output is correct
47 Correct 37 ms 33992 KB Output is correct
48 Correct 64 ms 62288 KB Output is correct
49 Correct 72 ms 62372 KB Output is correct
50 Correct 50 ms 34116 KB Output is correct
51 Correct 6 ms 452 KB Output is correct
52 Correct 82 ms 76364 KB Output is correct
53 Correct 58 ms 56140 KB Output is correct
54 Correct 84 ms 78924 KB Output is correct
55 Correct 191 ms 155248 KB Output is correct
56 Correct 96 ms 69452 KB Output is correct
57 Correct 168 ms 163536 KB Output is correct
58 Correct 94 ms 86680 KB Output is correct
59 Correct 110 ms 107724 KB Output is correct
60 Correct 11 ms 596 KB Output is correct
61 Correct 139 ms 120636 KB Output is correct
62 Correct 133 ms 122808 KB Output is correct
63 Correct 133 ms 132944 KB Output is correct
64 Correct 145 ms 128720 KB Output is correct
65 Correct 63 ms 61844 KB Output is correct
66 Correct 70 ms 66744 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 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 1 ms 468 KB Output is correct
13 Correct 0 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 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 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 2644 KB Output is correct
25 Correct 7 ms 4180 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 5 ms 4456 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 5 ms 4792 KB Output is correct
30 Correct 3 ms 3028 KB Output is correct
31 Correct 5 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 4820 KB Output is correct
34 Correct 5 ms 4876 KB Output is correct
35 Correct 5 ms 4692 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 20 ms 16904 KB Output is correct
38 Correct 22 ms 17372 KB Output is correct
39 Correct 62 ms 61908 KB Output is correct
40 Correct 40 ms 36532 KB Output is correct
41 Correct 85 ms 79232 KB Output is correct
42 Correct 33 ms 31564 KB Output is correct
43 Correct 58 ms 54856 KB Output is correct
44 Correct 65 ms 56844 KB Output is correct
45 Correct 68 ms 57684 KB Output is correct
46 Correct 37 ms 35276 KB Output is correct
47 Correct 37 ms 33992 KB Output is correct
48 Correct 64 ms 62288 KB Output is correct
49 Correct 72 ms 62372 KB Output is correct
50 Correct 50 ms 34116 KB Output is correct
51 Correct 6 ms 452 KB Output is correct
52 Correct 82 ms 76364 KB Output is correct
53 Correct 58 ms 56140 KB Output is correct
54 Correct 84 ms 78924 KB Output is correct
55 Correct 191 ms 155248 KB Output is correct
56 Correct 96 ms 69452 KB Output is correct
57 Correct 168 ms 163536 KB Output is correct
58 Correct 94 ms 86680 KB Output is correct
59 Correct 110 ms 107724 KB Output is correct
60 Correct 11 ms 596 KB Output is correct
61 Correct 139 ms 120636 KB Output is correct
62 Correct 133 ms 122808 KB Output is correct
63 Correct 133 ms 132944 KB Output is correct
64 Correct 145 ms 128720 KB Output is correct
65 Correct 63 ms 61844 KB Output is correct
66 Correct 70 ms 66744 KB Output is correct
67 Correct 134 ms 128580 KB Output is correct
68 Correct 29 ms 724 KB Output is correct
69 Runtime error 208 ms 262144 KB Execution killed with signal 9
70 Halted 0 ms 0 KB -