답안 #92782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92782 2019-01-04T13:53:20 Z toloraia Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 4604 KB
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

const int N = 505, M = 260010;
const int B = 1e9 + 7;

int n;
int a[N];
bool F[M], f;
int S;
int DP[M];
int dp[M];
int ans[M], ANS[M];
int V[M], np;
int i, j, i1;
int main()
{
    cin>>n;
    for (i = 1; i <= n; i++){
        cin>>a[i];
        S += a[i];
    }
    sort (a + 1, a + n + 1);
    bool ok = 0;
    for (i = 2; i <= n; i++)
        if ((a[i] - a[i - 1]) % 2 == 1)
            ok = 1;
    if (S % 2 == 1)
        ok = 1;
    if (ok){
        cout<<0<<endl;
        return 0;
    }
    F[0] = 1;
    DP[0] = 1;
    for (i = 1; i <= n; i++){
        for (j = S; j >= a[i]; j--)
            if (F[j - a[i]]){
                F[j] = 1;
                DP[j] += DP[j - a[i]];
                if (DP[j] > B)
                    DP[j] -= B;
            }
    }
    if (F[S / 2] == 0){
        cout<<0<<endl;
        return 0;
    }
    for (i = 0; i <= S; i++)
        if (F[i])
            V[np++] = i;
    for (int I = 1; I <= n; ++I){
        for (i1 = 0; i1 < np; ++i1){
            i = V[i1];
            dp[i] = DP[i];
            ans[abs (S - 2 * i - a[I])] = 0;
        }
        for (i1 = 0; i1 < np; ++i1){
            i = V[i1];
                f = 1;
                if (i >= a[I]){
                    f = 0;
                        dp[i] -= dp[i - a[I]];
                        if (dp[i] < 0)
                            dp[i] += B;
                        if (dp[i])
                            f = 1;
                }
                if (f && ans[abs (S - a[I] - 2 * i)] == 0){
                    ans[abs (S - a[I] - 2 * i)] = 1;
                    ANS[abs (S - a[I] - 2 * i)]++;
                }
            }
    }
    np = 0;
    for (i = 1; i <= S; i++)
        if (ANS[i] == n)
            V[np++] = i;
    cout<<np<<endl;
    for (i = 0; i < np; i++)
        cout<<V[i]<<" ";
    cout<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 6 ms 508 KB Output is correct
25 Correct 9 ms 504 KB Output is correct
26 Correct 10 ms 572 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 8 ms 504 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 9 ms 504 KB Output is correct
32 Correct 7 ms 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 3 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 6 ms 508 KB Output is correct
25 Correct 9 ms 504 KB Output is correct
26 Correct 10 ms 572 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 8 ms 504 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 9 ms 504 KB Output is correct
32 Correct 7 ms 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 3 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
37 Correct 44 ms 760 KB Output is correct
38 Correct 45 ms 868 KB Output is correct
39 Correct 15 ms 1400 KB Output is correct
40 Correct 100 ms 1064 KB Output is correct
41 Correct 18 ms 1528 KB Output is correct
42 Correct 85 ms 1016 KB Output is correct
43 Correct 148 ms 1628 KB Output is correct
44 Correct 156 ms 1784 KB Output is correct
45 Correct 158 ms 1656 KB Output is correct
46 Correct 58 ms 888 KB Output is correct
47 Correct 94 ms 1064 KB Output is correct
48 Correct 140 ms 1628 KB Output is correct
49 Correct 94 ms 1528 KB Output is correct
50 Correct 97 ms 1144 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 196 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 6 ms 508 KB Output is correct
25 Correct 9 ms 504 KB Output is correct
26 Correct 10 ms 572 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 8 ms 504 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 9 ms 504 KB Output is correct
32 Correct 7 ms 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 3 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
37 Correct 44 ms 760 KB Output is correct
38 Correct 45 ms 868 KB Output is correct
39 Correct 15 ms 1400 KB Output is correct
40 Correct 100 ms 1064 KB Output is correct
41 Correct 18 ms 1528 KB Output is correct
42 Correct 85 ms 1016 KB Output is correct
43 Correct 148 ms 1628 KB Output is correct
44 Correct 156 ms 1784 KB Output is correct
45 Correct 158 ms 1656 KB Output is correct
46 Correct 58 ms 888 KB Output is correct
47 Correct 94 ms 1064 KB Output is correct
48 Correct 140 ms 1628 KB Output is correct
49 Correct 94 ms 1528 KB Output is correct
50 Correct 97 ms 1144 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 196 ms 1912 KB Output is correct
53 Correct 161 ms 1400 KB Output is correct
54 Correct 226 ms 1696 KB Output is correct
55 Correct 415 ms 2936 KB Output is correct
56 Correct 198 ms 1656 KB Output is correct
57 Correct 451 ms 3064 KB Output is correct
58 Correct 244 ms 1912 KB Output is correct
59 Correct 309 ms 2168 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 389 ms 2312 KB Output is correct
62 Correct 338 ms 2552 KB Output is correct
63 Correct 374 ms 2792 KB Output is correct
64 Correct 359 ms 2680 KB Output is correct
65 Correct 29 ms 1144 KB Output is correct
66 Correct 60 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 6 ms 508 KB Output is correct
25 Correct 9 ms 504 KB Output is correct
26 Correct 10 ms 572 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 8 ms 504 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 9 ms 504 KB Output is correct
32 Correct 7 ms 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 3 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 7 ms 504 KB Output is correct
37 Correct 44 ms 760 KB Output is correct
38 Correct 45 ms 868 KB Output is correct
39 Correct 15 ms 1400 KB Output is correct
40 Correct 100 ms 1064 KB Output is correct
41 Correct 18 ms 1528 KB Output is correct
42 Correct 85 ms 1016 KB Output is correct
43 Correct 148 ms 1628 KB Output is correct
44 Correct 156 ms 1784 KB Output is correct
45 Correct 158 ms 1656 KB Output is correct
46 Correct 58 ms 888 KB Output is correct
47 Correct 94 ms 1064 KB Output is correct
48 Correct 140 ms 1628 KB Output is correct
49 Correct 94 ms 1528 KB Output is correct
50 Correct 97 ms 1144 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 196 ms 1912 KB Output is correct
53 Correct 161 ms 1400 KB Output is correct
54 Correct 226 ms 1696 KB Output is correct
55 Correct 415 ms 2936 KB Output is correct
56 Correct 198 ms 1656 KB Output is correct
57 Correct 451 ms 3064 KB Output is correct
58 Correct 244 ms 1912 KB Output is correct
59 Correct 309 ms 2168 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 389 ms 2312 KB Output is correct
62 Correct 338 ms 2552 KB Output is correct
63 Correct 374 ms 2792 KB Output is correct
64 Correct 359 ms 2680 KB Output is correct
65 Correct 29 ms 1144 KB Output is correct
66 Correct 60 ms 1272 KB Output is correct
67 Correct 366 ms 2188 KB Output is correct
68 Correct 53 ms 1016 KB Output is correct
69 Execution timed out 1081 ms 4604 KB Time limit exceeded
70 Halted 0 ms 0 KB -