Submission #953725

# Submission time Handle Problem Language Result Execution time Memory
953725 2024-03-26T14:39:25 Z nguyennh Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 600 KB
#include<bits/stdc++.h>
#define el '\n'
using namespace std ;

int n;

namespace sub_trau{
  void solve(){
    vector<int> a(n + 5);
    for ( int i = 1 ; i <= n ; i++ ) cin >> a[i];
    int sum = accumulate(a.begin() + 1 , a.begin() + n + 1 , 0);
    vector<int> ans;
    for ( int val = 1 ; val <= sum ; val++ ){
      vector<int> candidates;
      int all = sum + val;
      for ( int i = 1 ; i <= n ; i++ ) candidates.push_back(a[i]);
      candidates.push_back(val);
      bool check = true;
      for ( int turn = 0 ; turn < n + 1 ; turn++ ){
        int need = all - candidates[turn];
        if (need & 1){
          check = false;
          break;
        }
        deque<int> cur;
        for ( int j = 0 ; j < candidates.size() ; j++ ){
          if (j == turn) continue;
          cur.push_back(candidates[j]);
        }
        cur.push_front(-1);
        vector<vector<bool>> dp(n + 5 , vector<bool> (need / 2 + 5));
        dp[0][0] = 1;
        for ( int i = 1 ; i <= n ; i++ ){
          for ( int j = 0 ; j <= need / 2 ; j++ ){
            dp[i][j] = dp[i - 1][j];
            if (j >= cur[i] && dp[i - 1][j - cur[i]]){
              dp[i][j] = 1;
            }
          }
        }
        if (!dp[n][need / 2]){
          check = false;
          break;
        }
      }
      if (check) ans.push_back(val);
    }
    cout << ans.size() << el;
    for ( auto x : ans ) cout << x << " ";
  }
}

int32_t main (){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  sub_trau::solve();
}

Compilation message

bootfall.cpp: In function 'void sub_trau::solve()':
bootfall.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for ( int j = 0 ; j < candidates.size() ; j++ ){
      |                           ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 73 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 144 ms 460 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 73 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 144 ms 460 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
10 Correct 47 ms 456 KB Output is correct
11 Correct 82 ms 436 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 93 ms 448 KB Output is correct
15 Correct 55 ms 440 KB Output is correct
16 Correct 81 ms 600 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 49 ms 348 KB Output is correct
19 Correct 39 ms 432 KB Output is correct
20 Correct 35 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 73 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 144 ms 460 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
10 Correct 47 ms 456 KB Output is correct
11 Correct 82 ms 436 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 93 ms 448 KB Output is correct
15 Correct 55 ms 440 KB Output is correct
16 Correct 81 ms 600 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 49 ms 348 KB Output is correct
19 Correct 39 ms 432 KB Output is correct
20 Correct 35 ms 452 KB Output is correct
21 Execution timed out 1059 ms 460 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 73 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 144 ms 460 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
10 Correct 47 ms 456 KB Output is correct
11 Correct 82 ms 436 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 93 ms 448 KB Output is correct
15 Correct 55 ms 440 KB Output is correct
16 Correct 81 ms 600 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 49 ms 348 KB Output is correct
19 Correct 39 ms 432 KB Output is correct
20 Correct 35 ms 452 KB Output is correct
21 Execution timed out 1059 ms 460 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 73 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 144 ms 460 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
10 Correct 47 ms 456 KB Output is correct
11 Correct 82 ms 436 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 93 ms 448 KB Output is correct
15 Correct 55 ms 440 KB Output is correct
16 Correct 81 ms 600 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 49 ms 348 KB Output is correct
19 Correct 39 ms 432 KB Output is correct
20 Correct 35 ms 452 KB Output is correct
21 Execution timed out 1059 ms 460 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 73 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 144 ms 460 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
10 Correct 47 ms 456 KB Output is correct
11 Correct 82 ms 436 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 93 ms 448 KB Output is correct
15 Correct 55 ms 440 KB Output is correct
16 Correct 81 ms 600 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 49 ms 348 KB Output is correct
19 Correct 39 ms 432 KB Output is correct
20 Correct 35 ms 452 KB Output is correct
21 Execution timed out 1059 ms 460 KB Time limit exceeded
22 Halted 0 ms 0 KB -