제출 #331659

#제출 시각아이디문제언어결과실행 시간메모리
331659vitkishloh228Bootfall (IZhO17_bootfall)C++14
13 / 100
1057 ms524 KiB
#include<iostream> #include<vector> #include<algorithm> #include<bitset> using namespace std; const int maxc = 10000; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int S = 0; for (auto elem : a) { S += elem; } bitset<maxc> dp1; dp1[0] = 1; for (int i = 0; i < n; i++) { dp1 |= dp1 << a[i]; } vector<int> ans; for (int L = 0; L < 3000; ++L) { int needsum = (S + L); //if ((S + L) % 2 == 1) continue; bool ok = dp1[S / 2]; //cout << ok << endl; for (int j = 0; j < n; ++j) { if ((S + L - a[j]) % 2 == 1) { ok = false; break; } bitset<maxc> dp; dp[0] = 1; for (int i = 0; i < n; i++) { if (i == j) continue; dp |= dp << a[i]; } dp |= dp << L; if (!dp[(S + L - a[j]) / 2]) { ok = false; break; } } if (ok) { ans.push_back(L); } } cout << ans.size() << '\n'; for (auto elem : ans) cout << elem << ' '; }

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

bootfall.cpp: In function 'int main()':
bootfall.cpp:23:13: warning: unused variable 'needsum' [-Wunused-variable]
   23 |         int needsum = (S + L);
      |             ^~~~~~~
#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...