답안 #92754

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

const int N = 505, M = 260010;
const ll B = 1e18;

int n;
int a[N];
bool F[M], f[M];
int S;
ll DP[M][10];
ll dp[M][10];
int ans[M], ANS[M];
vector < int > V, v;

int main()
{
    cin>>n;
    for (int i = 1; i <= n; i++){
        cin>>a[i];
        S += a[i];
    }
    sort (a + 1, a + n + 1);
    bool ok = 0;
    for (int 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][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = S; j >= a[i]; j--)
            if (F[j - a[i]]){
                F[j] = 1;
                for (int l = 0; l < 9; l++){
                    DP[j][l] += DP[j - a[i]][l];
                    if (DP[j][l] >= B){
                        DP[j][l + 1]++;
                        DP[j][l] -= B;
                    }
                }
            }
    }
    if (F[S / 2] == 0){
        cout<<0<<endl;
        return 0;
    }
    for (int i = 0; i <= S; i++)
        if (F[i])
            V.push_back (i);
    for (int I = 1; I <= n; I++){
        for (int i1 = 0; i1 < (int)V.size(); i1++){
            int i = V[i1];
            for (int j = 0; j < 9; j++)
                dp[i][j] = DP[i][j];
            ans[abs (S - 2 * i - a[I])] = 0;
        }
        for (int i1 = 0; i1 < (int)V.size(); i1++){
            int i = V[i1];
                f[i] = 1;
                if (i >= a[I]){
                    f[i] = 0;
                    for (int j = 0; j < 9; j++){
                        dp[i][j] -= dp[i - a[I]][j];
                        if (dp[i][j] < 0){
                            dp[i][j] += B;
                            dp[i][j + 1]--;
                        }
                        if (dp[i][j])
                            f[i] = 1;
                    }
                }
                if (f[i] && ans[abs (S - a[I] - 2 * i)] == 0){
                    ans[abs (S - a[I] - 2 * i)] = 1;
                    ANS[abs (S - a[I] - 2 * i)]++;
                }
            }
    }
    V.clear();
    for (int i = 1; i <= S; i++)
        if (ANS[i] == n)
            V.push_back (i);
    cout<<(int)V.size()<<endl;
    for (int i = 0; i < (int)V.size(); 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 504 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 632 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 504 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 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 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 360 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 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 504 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 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 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 360 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 504 KB Output is correct
21 Correct 8 ms 888 KB Output is correct
22 Correct 10 ms 1016 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 19 ms 1252 KB Output is correct
25 Correct 28 ms 1952 KB Output is correct
26 Correct 31 ms 1912 KB Output is correct
27 Correct 21 ms 1916 KB Output is correct
28 Correct 18 ms 1912 KB Output is correct
29 Correct 22 ms 2036 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 65 ms 1656 KB Output is correct
32 Correct 20 ms 1144 KB Output is correct
33 Correct 3 ms 1272 KB Output is correct
34 Correct 3 ms 1272 KB Output is correct
35 Correct 18 ms 1912 KB Output is correct
36 Correct 35 ms 1144 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 504 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 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 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 360 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 504 KB Output is correct
21 Correct 8 ms 888 KB Output is correct
22 Correct 10 ms 1016 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 19 ms 1252 KB Output is correct
25 Correct 28 ms 1952 KB Output is correct
26 Correct 31 ms 1912 KB Output is correct
27 Correct 21 ms 1916 KB Output is correct
28 Correct 18 ms 1912 KB Output is correct
29 Correct 22 ms 2036 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 65 ms 1656 KB Output is correct
32 Correct 20 ms 1144 KB Output is correct
33 Correct 3 ms 1272 KB Output is correct
34 Correct 3 ms 1272 KB Output is correct
35 Correct 18 ms 1912 KB Output is correct
36 Correct 35 ms 1144 KB Output is correct
37 Correct 181 ms 3868 KB Output is correct
38 Correct 180 ms 3960 KB Output is correct
39 Correct 17 ms 2936 KB Output is correct
40 Correct 451 ms 6136 KB Output is correct
41 Correct 21 ms 3320 KB Output is correct
42 Correct 370 ms 5724 KB Output is correct
43 Correct 679 ms 9856 KB Output is correct
44 Correct 705 ms 10080 KB Output is correct
45 Correct 693 ms 10228 KB Output is correct
46 Correct 251 ms 5800 KB Output is correct
47 Correct 395 ms 6108 KB Output is correct
48 Correct 588 ms 10316 KB Output is correct
49 Correct 377 ms 9464 KB Output is correct
50 Correct 395 ms 6136 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 940 ms 12332 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 504 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 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 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 360 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 504 KB Output is correct
21 Correct 8 ms 888 KB Output is correct
22 Correct 10 ms 1016 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 19 ms 1252 KB Output is correct
25 Correct 28 ms 1952 KB Output is correct
26 Correct 31 ms 1912 KB Output is correct
27 Correct 21 ms 1916 KB Output is correct
28 Correct 18 ms 1912 KB Output is correct
29 Correct 22 ms 2036 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 65 ms 1656 KB Output is correct
32 Correct 20 ms 1144 KB Output is correct
33 Correct 3 ms 1272 KB Output is correct
34 Correct 3 ms 1272 KB Output is correct
35 Correct 18 ms 1912 KB Output is correct
36 Correct 35 ms 1144 KB Output is correct
37 Correct 181 ms 3868 KB Output is correct
38 Correct 180 ms 3960 KB Output is correct
39 Correct 17 ms 2936 KB Output is correct
40 Correct 451 ms 6136 KB Output is correct
41 Correct 21 ms 3320 KB Output is correct
42 Correct 370 ms 5724 KB Output is correct
43 Correct 679 ms 9856 KB Output is correct
44 Correct 705 ms 10080 KB Output is correct
45 Correct 693 ms 10228 KB Output is correct
46 Correct 251 ms 5800 KB Output is correct
47 Correct 395 ms 6108 KB Output is correct
48 Correct 588 ms 10316 KB Output is correct
49 Correct 377 ms 9464 KB Output is correct
50 Correct 395 ms 6136 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 940 ms 12332 KB Output is correct
53 Correct 746 ms 8400 KB Output is correct
54 Execution timed out 1082 ms 9928 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 504 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 632 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 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 360 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 504 KB Output is correct
21 Correct 8 ms 888 KB Output is correct
22 Correct 10 ms 1016 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 19 ms 1252 KB Output is correct
25 Correct 28 ms 1952 KB Output is correct
26 Correct 31 ms 1912 KB Output is correct
27 Correct 21 ms 1916 KB Output is correct
28 Correct 18 ms 1912 KB Output is correct
29 Correct 22 ms 2036 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 65 ms 1656 KB Output is correct
32 Correct 20 ms 1144 KB Output is correct
33 Correct 3 ms 1272 KB Output is correct
34 Correct 3 ms 1272 KB Output is correct
35 Correct 18 ms 1912 KB Output is correct
36 Correct 35 ms 1144 KB Output is correct
37 Correct 181 ms 3868 KB Output is correct
38 Correct 180 ms 3960 KB Output is correct
39 Correct 17 ms 2936 KB Output is correct
40 Correct 451 ms 6136 KB Output is correct
41 Correct 21 ms 3320 KB Output is correct
42 Correct 370 ms 5724 KB Output is correct
43 Correct 679 ms 9856 KB Output is correct
44 Correct 705 ms 10080 KB Output is correct
45 Correct 693 ms 10228 KB Output is correct
46 Correct 251 ms 5800 KB Output is correct
47 Correct 395 ms 6108 KB Output is correct
48 Correct 588 ms 10316 KB Output is correct
49 Correct 377 ms 9464 KB Output is correct
50 Correct 395 ms 6136 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 940 ms 12332 KB Output is correct
53 Correct 746 ms 8400 KB Output is correct
54 Execution timed out 1082 ms 9928 KB Time limit exceeded
55 Halted 0 ms 0 KB -