제출 #92825

#제출 시각아이디문제언어결과실행 시간메모리
92825SamAndBootfall (IZhO17_bootfall)C++17
28 / 100
200 ms263168 KiB
#include <bits/stdc++.h> using namespace std; const int N = 502; int n; int a[N]; int m; int u[N][N * N]; int main() { //freopen("input2.txt", "r", stdin); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; m += a[i]; } u[0][0] = 1; for (int i = 1; i <= n; ++i) { for (int j = m; j >= 0; --j) { if (j + a[i] <= m) u[0][j + a[i]] += u[0][j]; } } for (int i = 1; i <= n; ++i) memcpy(u[i], u[0], sizeof u[0]); for (int i = 1; i <= n; ++i) { for (int j = 0; j <= m; ++j) { if (j + a[i] <= m) u[i][j + a[i]] -= u[i][j]; } } if ((m % 2) == 1 || !u[0][m / 2]) { cout << 0 << endl; return 0; } vector<int> ans; for (int x = 1; x <= m; ++x) { bool z = true; for (int i = 1; i <= n; ++i) { int y = (m - a[i] + x) / 2; if (!((m - a[i] + x) % 2 == 0 && y <= m && u[i][y])) { z = false; break; } } if (z) ans.push_back(x); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' '; cout << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bootfall.cpp: In function 'int main()':
bootfall.cpp:68:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     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...