Submission #541011

# Submission time Handle Problem Language Result Execution time Memory
541011 2022-03-22T06:24:50 Z vinnipuh01 Bootfall (IZhO17_bootfall) C++17
13 / 100
1000 ms 432 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>

using namespace std;

const long long oo = 1000000000000000000;

long long int  sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen ( "sum.in", "r", stdin )
*/

int n, a[ 5001 ], dp[ 250001 ];
vector <int> v;

bool ok( int x ) {
	a[ n + 1 ] = x;
	for ( int i = 1; i <= n + 1; i ++ ) {
		num = sum + x - a[ i ];
		if ( num % 2 )
			return false;
		num /= 2;
		for ( int k = num; k >= 1; k -- )
			dp[ k ] = 0;
		dp[ 0 ] = 1;
		for ( int j = 1; j <= n + 1; j ++ ) {
			if ( j == i )
				continue;
			for ( int k = num; k >= 0; k -- ) {
				if ( dp[ k ] && k + a[ j ] <= num ) {
					dp[ k + a[ j ] ] = 1;
				}
			}
		}
		if ( !dp[ num ] ) {
			return false;
		}
	}
	return true;
}

int main () {
	cin >> n;
	for ( int i = 1; i <= n; i ++ )
		cin >> a[ i ], sum += a[ i ];
	for ( int i = 1; i <= 1000; i ++ ) {
		if ( ok( i ) )
			v.push_back( i );
	}
	cout << v.size() << "\n";
	for ( auto i : v )
		cout << i << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 40 ms 304 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 40 ms 304 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 60 ms 212 KB Output is correct
12 Correct 12 ms 432 KB Output is correct
13 Correct 11 ms 312 KB Output is correct
14 Correct 57 ms 292 KB Output is correct
15 Correct 33 ms 312 KB Output is correct
16 Correct 48 ms 312 KB Output is correct
17 Correct 12 ms 212 KB Output is correct
18 Correct 29 ms 300 KB Output is correct
19 Correct 27 ms 212 KB Output is correct
20 Correct 17 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 40 ms 304 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 60 ms 212 KB Output is correct
12 Correct 12 ms 432 KB Output is correct
13 Correct 11 ms 312 KB Output is correct
14 Correct 57 ms 292 KB Output is correct
15 Correct 33 ms 312 KB Output is correct
16 Correct 48 ms 312 KB Output is correct
17 Correct 12 ms 212 KB Output is correct
18 Correct 29 ms 300 KB Output is correct
19 Correct 27 ms 212 KB Output is correct
20 Correct 17 ms 312 KB Output is correct
21 Execution timed out 1082 ms 212 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 40 ms 304 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 60 ms 212 KB Output is correct
12 Correct 12 ms 432 KB Output is correct
13 Correct 11 ms 312 KB Output is correct
14 Correct 57 ms 292 KB Output is correct
15 Correct 33 ms 312 KB Output is correct
16 Correct 48 ms 312 KB Output is correct
17 Correct 12 ms 212 KB Output is correct
18 Correct 29 ms 300 KB Output is correct
19 Correct 27 ms 212 KB Output is correct
20 Correct 17 ms 312 KB Output is correct
21 Execution timed out 1082 ms 212 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 40 ms 304 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 60 ms 212 KB Output is correct
12 Correct 12 ms 432 KB Output is correct
13 Correct 11 ms 312 KB Output is correct
14 Correct 57 ms 292 KB Output is correct
15 Correct 33 ms 312 KB Output is correct
16 Correct 48 ms 312 KB Output is correct
17 Correct 12 ms 212 KB Output is correct
18 Correct 29 ms 300 KB Output is correct
19 Correct 27 ms 212 KB Output is correct
20 Correct 17 ms 312 KB Output is correct
21 Execution timed out 1082 ms 212 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 40 ms 304 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 60 ms 212 KB Output is correct
12 Correct 12 ms 432 KB Output is correct
13 Correct 11 ms 312 KB Output is correct
14 Correct 57 ms 292 KB Output is correct
15 Correct 33 ms 312 KB Output is correct
16 Correct 48 ms 312 KB Output is correct
17 Correct 12 ms 212 KB Output is correct
18 Correct 29 ms 300 KB Output is correct
19 Correct 27 ms 212 KB Output is correct
20 Correct 17 ms 312 KB Output is correct
21 Execution timed out 1082 ms 212 KB Time limit exceeded
22 Halted 0 ms 0 KB -