제출 #488314

#제출 시각아이디문제언어결과실행 시간메모리
488314OttincaMBootfall (IZhO17_bootfall)C++14
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; int a[501], f[250001], ans[250001], Ans, t; int main(){ int n, s = 0; cin >> n; f[0] = 1; ans[0] = n + 1; for(int i = 1; i <= n; i ++){ cin >> a[i]; for(int j = s; j >= 0; j --) f[j + a[i]] += f[j]; s += a[i]; } for(int i = 1; i <= n; i ++){ s -= a[i]; for(int j = 0; j <= s; j ++){ f[j + a[i]] -= f[j]; ans[max(j + j - s, 0)] += (!!f[j]); Ans += (ans[max(j + j - s, 0)] == n); } for(int j = s; j >= 0; j --){ f[j + a[i]] += f[j]; s += a[i]; } } if(s & 1 || !f[s / 2]){ cout << 0; return 0; } cout << Ans << '\n'; for(int i = 1; i <= s; i ++) if(ans[i] == n) cout << 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...