이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |