Submission #682012

# Submission time Handle Problem Language Result Execution time Memory
682012 2023-01-15T08:33:50 Z boykut Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX = 1000;
int dp[MAX*MAX], can[MAX*MAX];
int a[MAX];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int x = sum; x >= 0; x--) {
      dp[x+a[i]] += dp[x];
    }
  }
  
  if (sum%2 == 1 || dp[sum/2] == 0) {
    return cout << 0, 0;
  }
  
  fill(can, can+sum+1, 1);
  
  vector<int> ans;
  
  for (int Without = 0; Without < n; Without++) {
    fill(dp, dp+sum+1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
      for (int x = sum; x >= 0; x--) {
        if (i != Without)
          dp[x+a[i]] += dp[x];
      }
    }
    // a[Without] êàìåðà êàðìàï òóðàò
    for (int Tima = 1; Tima <= sum; Tima++) {
      if ((sum-a[Without]+Tima)%2 == 1 || dp[(sum-a[Without]+Tima)/2] == 0) {
        can[Tima] = 0;
      }
    }
  }
  
  for (int Tima = 1; Tima <= sum; Tima++) {
    if (can[Tima] == 1) {
      ans.push_back(Tima);
    }
  }
  
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:59:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   for (int i = 0; i < ans.size(); i++) {
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 33 ms 356 KB Output is correct
22 Correct 53 ms 344 KB Output is correct
23 Correct 17 ms 340 KB Output is correct
24 Correct 117 ms 348 KB Output is correct
25 Correct 232 ms 388 KB Output is correct
26 Correct 262 ms 392 KB Output is correct
27 Correct 259 ms 384 KB Output is correct
28 Correct 246 ms 460 KB Output is correct
29 Correct 283 ms 388 KB Output is correct
30 Correct 154 ms 340 KB Output is correct
31 Correct 204 ms 380 KB Output is correct
32 Correct 125 ms 352 KB Output is correct
33 Correct 292 ms 392 KB Output is correct
34 Correct 267 ms 340 KB Output is correct
35 Correct 276 ms 396 KB Output is correct
36 Correct 119 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 33 ms 356 KB Output is correct
22 Correct 53 ms 344 KB Output is correct
23 Correct 17 ms 340 KB Output is correct
24 Correct 117 ms 348 KB Output is correct
25 Correct 232 ms 388 KB Output is correct
26 Correct 262 ms 392 KB Output is correct
27 Correct 259 ms 384 KB Output is correct
28 Correct 246 ms 460 KB Output is correct
29 Correct 283 ms 388 KB Output is correct
30 Correct 154 ms 340 KB Output is correct
31 Correct 204 ms 380 KB Output is correct
32 Correct 125 ms 352 KB Output is correct
33 Correct 292 ms 392 KB Output is correct
34 Correct 267 ms 340 KB Output is correct
35 Correct 276 ms 396 KB Output is correct
36 Correct 119 ms 352 KB Output is correct
37 Execution timed out 1092 ms 468 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 33 ms 356 KB Output is correct
22 Correct 53 ms 344 KB Output is correct
23 Correct 17 ms 340 KB Output is correct
24 Correct 117 ms 348 KB Output is correct
25 Correct 232 ms 388 KB Output is correct
26 Correct 262 ms 392 KB Output is correct
27 Correct 259 ms 384 KB Output is correct
28 Correct 246 ms 460 KB Output is correct
29 Correct 283 ms 388 KB Output is correct
30 Correct 154 ms 340 KB Output is correct
31 Correct 204 ms 380 KB Output is correct
32 Correct 125 ms 352 KB Output is correct
33 Correct 292 ms 392 KB Output is correct
34 Correct 267 ms 340 KB Output is correct
35 Correct 276 ms 396 KB Output is correct
36 Correct 119 ms 352 KB Output is correct
37 Execution timed out 1092 ms 468 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 33 ms 356 KB Output is correct
22 Correct 53 ms 344 KB Output is correct
23 Correct 17 ms 340 KB Output is correct
24 Correct 117 ms 348 KB Output is correct
25 Correct 232 ms 388 KB Output is correct
26 Correct 262 ms 392 KB Output is correct
27 Correct 259 ms 384 KB Output is correct
28 Correct 246 ms 460 KB Output is correct
29 Correct 283 ms 388 KB Output is correct
30 Correct 154 ms 340 KB Output is correct
31 Correct 204 ms 380 KB Output is correct
32 Correct 125 ms 352 KB Output is correct
33 Correct 292 ms 392 KB Output is correct
34 Correct 267 ms 340 KB Output is correct
35 Correct 276 ms 396 KB Output is correct
36 Correct 119 ms 352 KB Output is correct
37 Execution timed out 1092 ms 468 KB Time limit exceeded
38 Halted 0 ms 0 KB -