답안 #500863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500863 2022-01-01T13:36:47 Z EliteCallsYou Bootfall (IZhO17_bootfall) C++17
28 / 100
389 ms 4280 KB
# include <bits/stdc++.h>
using namespace std ;
//############################################################################
# define read(a)/**/for(int i=0;i<int(sizeof(a)/sizeof(a[0]));i++){cin>>a[i];}
# define print(x)/**/for(auto zx:x){cout<<zx<<' ';}
const char* tochar(string a){return a.c_str();}
void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
void speed(){ios_base::sync_with_stdio(false);cin.tie(0);}
long long gcd(long long a,long long b){if(!b){return a;}a%=b;return gcd(b,a);}
long long lcm(long long a,long long b){return a /gcd(a,b) * b;}
//###########################################################################
const int N = 3e5 + 5 ;
const long long MOD = 1e17+7 ;
//###########################################################################
void hack(){}
//###########################################################################
int main(){
	int n, sum = 0 ; cin >> n ;
	int ar[n+1] ;
	for ( int i = 1 ; i <= n ; i ++ ){
		cin >> ar[i] ;
		sum += ar[i] ;
	}
	if ( sum%2 ){
		cout << "0\n";
		return 0 ;
	}
	
	bool dp[n+1][10001] = {false} ;
	for ( int i = 0 ; i <= n ; i ++ ){
		dp[i][0] = true ;

		for ( int it = 1 ; it <= n ; it ++ ){
			if ( it == i ){continue;}
			for ( int j = 10001-ar[it] ; j > -1 ; j -- ){
				if ( dp[i][j] ){
					dp[i][j+ar[it]] = true ;
				}
			}
		}
	}


	if ( !dp[0][sum/2] ){
		cout << "0\n" ;
		return 0 ;
	}

	vector < int > ans ;
	for ( int cur = 1 ; cur <= sum ; cur ++ ){

		bool ok = true ;

		for ( int j = 1 ; j <= n ; j ++ ){
			int s = sum-ar[j]+cur ;
			if ( s%2 || s < 0 ){
				ok = false ;
				break ;
			}
			if ( !dp[j][s/2] ){
				ok = false ;
				break ;
			}
		}
		if ( ok ){
			ans.push_back(cur) ;
		}
	}


	cout << ans.size() << '\n' ;
	for ( auto it : ans ){
		cout << it << ' ' ;
	}
}	

Compilation message

bootfall.cpp: In function 'void files()':
bootfall.cpp:7:21: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
      |              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:7:54: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
      |                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 10 ms 588 KB Output is correct
11 Correct 15 ms 588 KB Output is correct
12 Correct 10 ms 588 KB Output is correct
13 Correct 7 ms 544 KB Output is correct
14 Correct 13 ms 460 KB Output is correct
15 Correct 14 ms 460 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 7 ms 536 KB Output is correct
19 Correct 7 ms 548 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 10 ms 588 KB Output is correct
11 Correct 15 ms 588 KB Output is correct
12 Correct 10 ms 588 KB Output is correct
13 Correct 7 ms 544 KB Output is correct
14 Correct 13 ms 460 KB Output is correct
15 Correct 14 ms 460 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 7 ms 536 KB Output is correct
19 Correct 7 ms 548 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
21 Correct 43 ms 912 KB Output is correct
22 Correct 56 ms 1000 KB Output is correct
23 Correct 26 ms 776 KB Output is correct
24 Correct 128 ms 1212 KB Output is correct
25 Correct 96 ms 1196 KB Output is correct
26 Correct 110 ms 1228 KB Output is correct
27 Correct 115 ms 1272 KB Output is correct
28 Correct 135 ms 1252 KB Output is correct
29 Correct 131 ms 1256 KB Output is correct
30 Correct 99 ms 1184 KB Output is correct
31 Correct 112 ms 1268 KB Output is correct
32 Correct 102 ms 1268 KB Output is correct
33 Correct 147 ms 1228 KB Output is correct
34 Correct 105 ms 1260 KB Output is correct
35 Correct 111 ms 1256 KB Output is correct
36 Correct 101 ms 1268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 10 ms 588 KB Output is correct
11 Correct 15 ms 588 KB Output is correct
12 Correct 10 ms 588 KB Output is correct
13 Correct 7 ms 544 KB Output is correct
14 Correct 13 ms 460 KB Output is correct
15 Correct 14 ms 460 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 7 ms 536 KB Output is correct
19 Correct 7 ms 548 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
21 Correct 43 ms 912 KB Output is correct
22 Correct 56 ms 1000 KB Output is correct
23 Correct 26 ms 776 KB Output is correct
24 Correct 128 ms 1212 KB Output is correct
25 Correct 96 ms 1196 KB Output is correct
26 Correct 110 ms 1228 KB Output is correct
27 Correct 115 ms 1272 KB Output is correct
28 Correct 135 ms 1252 KB Output is correct
29 Correct 131 ms 1256 KB Output is correct
30 Correct 99 ms 1184 KB Output is correct
31 Correct 112 ms 1268 KB Output is correct
32 Correct 102 ms 1268 KB Output is correct
33 Correct 147 ms 1228 KB Output is correct
34 Correct 105 ms 1260 KB Output is correct
35 Correct 111 ms 1256 KB Output is correct
36 Correct 101 ms 1268 KB Output is correct
37 Runtime error 389 ms 4280 KB Execution killed with signal 11
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 10 ms 588 KB Output is correct
11 Correct 15 ms 588 KB Output is correct
12 Correct 10 ms 588 KB Output is correct
13 Correct 7 ms 544 KB Output is correct
14 Correct 13 ms 460 KB Output is correct
15 Correct 14 ms 460 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 7 ms 536 KB Output is correct
19 Correct 7 ms 548 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
21 Correct 43 ms 912 KB Output is correct
22 Correct 56 ms 1000 KB Output is correct
23 Correct 26 ms 776 KB Output is correct
24 Correct 128 ms 1212 KB Output is correct
25 Correct 96 ms 1196 KB Output is correct
26 Correct 110 ms 1228 KB Output is correct
27 Correct 115 ms 1272 KB Output is correct
28 Correct 135 ms 1252 KB Output is correct
29 Correct 131 ms 1256 KB Output is correct
30 Correct 99 ms 1184 KB Output is correct
31 Correct 112 ms 1268 KB Output is correct
32 Correct 102 ms 1268 KB Output is correct
33 Correct 147 ms 1228 KB Output is correct
34 Correct 105 ms 1260 KB Output is correct
35 Correct 111 ms 1256 KB Output is correct
36 Correct 101 ms 1268 KB Output is correct
37 Runtime error 389 ms 4280 KB Execution killed with signal 11
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 10 ms 588 KB Output is correct
11 Correct 15 ms 588 KB Output is correct
12 Correct 10 ms 588 KB Output is correct
13 Correct 7 ms 544 KB Output is correct
14 Correct 13 ms 460 KB Output is correct
15 Correct 14 ms 460 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 7 ms 536 KB Output is correct
19 Correct 7 ms 548 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
21 Correct 43 ms 912 KB Output is correct
22 Correct 56 ms 1000 KB Output is correct
23 Correct 26 ms 776 KB Output is correct
24 Correct 128 ms 1212 KB Output is correct
25 Correct 96 ms 1196 KB Output is correct
26 Correct 110 ms 1228 KB Output is correct
27 Correct 115 ms 1272 KB Output is correct
28 Correct 135 ms 1252 KB Output is correct
29 Correct 131 ms 1256 KB Output is correct
30 Correct 99 ms 1184 KB Output is correct
31 Correct 112 ms 1268 KB Output is correct
32 Correct 102 ms 1268 KB Output is correct
33 Correct 147 ms 1228 KB Output is correct
34 Correct 105 ms 1260 KB Output is correct
35 Correct 111 ms 1256 KB Output is correct
36 Correct 101 ms 1268 KB Output is correct
37 Runtime error 389 ms 4280 KB Execution killed with signal 11
38 Halted 0 ms 0 KB -