# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335548 | luciocf | Bootfall (IZhO17_bootfall) | C++14 | 720 ms | 3024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
const int maxs = 250010;
const int mod = 1e9+7;
int a[maxn];
int dp[maxs], qtd[maxs];
int main(void)
{
int n;
scanf("%d", &n);
int s = 0;
for (int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
s += a[i];
}
dp[0] = 1;
for (int i = 1; i <= n; i++)
for (int j = maxs-1; j >= a[i]; j--)
dp[j] = (dp[j] + dp[j - a[i]])%mod;
if (s&1 || !dp[s/2])
{
printf("0\n");
return 0;
}
for (int i = 1; i <= n; i++)
{
for (int j = a[i]; j < maxs; j++)
dp[j] = (dp[j] - dp[j - a[i]] + mod)%mod;
for (int j = (s-a[i]+1)/2; j < maxs; j++)
if (dp[j])
qtd[2*j-s+a[i]]++;
for (int j = maxs; j >= a[i]; j--)
dp[j] = (dp[j] + dp[j - a[i]])%mod;
}
int ans = 0;
for (int i = 1; i < maxs; i++)
if (qtd[i] == n)
ans++;
printf("%d\n", ans);
for (int i = 1; i < maxs; i++)
if (qtd[i] == n)
printf("%d ", i);
printf("\n");
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |