Submission #681988

#TimeUsernameProblemLanguageResultExecution timeMemory
681988boykutBootfall (IZhO17_bootfall)C++14
0 / 100
4 ms328 KiB
#include <bits/stdc++.h> using namespace std; const int MAXA = 20, MAXN = 30; int dp[MAXA*MAXA+1], cant[MAXA*MAXA+1]; int a[MAXN]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; dp[0] = 1; int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; for (int x = MAXA*MAXA-a[i]; x >= 0; x--) { dp[x + a[i]] += dp[x]; } } if (sum % 2 == 1 || dp[sum / 2] == 0) { return cout << 0, 0; } vector<int> ans; for (int Tima = 0; Tima <= MAXA*MAXA; Tima++) { for (int Without = 0; Without < n; Without++) { memset(dp, 0, sizeof dp); dp[0] = dp[Tima] = 1; sum += Tima - a[Without]; for (int i = 0; i < n; i++) { if (i == Without) continue; for (int x = MAXA*MAXA-a[i]; x >= 0; x--) { dp[x + a[i]] += dp[x]; } } if (sum % 2 == 1 || dp[sum / 2] == 0) cant[Tima] = 1; sum -= Tima - a[Without]; } } for (int Tima = 0; Tima <= MAXA*MAXA; Tima++) { if (cant[Tima] == 0) ans.push_back(Tima); } cout << ans.size() << "\n"; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << " "; } return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for (int i = 0; i < ans.size(); i++) {
      |                   ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...