답안 #243134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243134 2020-06-30T12:14:41 Z nicolaalexandra Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 27264 KB
#include <bits/stdc++.h>
#define DIM 2010
using namespace std;

int ok[DIM][DIM],v[DIM];
vector <int> L[DIM];
int n,a,b,val,i;

int verif (long long mask, int bit){
    int i,j,k;
    for (i=1;i<=n;i++)
        L[i].clear();
    for (i=1;i<=n;i++){
        long long sum = 0;
        for (j=i;j<=n;j++){
            sum += v[j];

            int ok = 1;
            for (k=val;k>=bit;k--){
                if ( (((mask>>k)&1) == 0) &&  (((sum>>k)&1) == 1) ){
                    ok = 0;
                    break;
                }
            }

            if (ok)
                L[j].push_back(i);
        }

    }

    /// ok[i][j] - daca pot imparti primele i nr in j subsecv
    memset (ok,0,sizeof ok);
    ok[0][0] = 1;
    for (i=1;i<=n;i++){
        for (j=1;j<=b;j++){
            for (auto poz : L[i]){
                if (ok[poz-1][j-1]){
                    ok[i][j] = 1;
                    break;
                }}}}

    for (i=a;i<=b;i++)
        if (ok[n][i])
            return 1;

    return 0;
}

int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>n>>a>>b;
    long long sum = 0;
    for (i=1;i<=n;i++){
        cin>>v[i];
        sum += v[i];
    }

    long long p = 1;
    val = 0;
    while (p * 2 <= sum){
        p *= 2;
        val++;
    }

    long long mask = 0;
    for (int bit=val;bit>=0;bit--){
        if (!verif (mask,bit))
            mask += (1LL<<bit);
    }

    cout<<mask;



    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 16128 KB Output is correct
2 Correct 19 ms 16128 KB Output is correct
3 Correct 12 ms 16256 KB Output is correct
4 Correct 22 ms 16128 KB Output is correct
5 Correct 21 ms 16256 KB Output is correct
6 Correct 21 ms 16256 KB Output is correct
7 Correct 23 ms 16256 KB Output is correct
8 Correct 23 ms 16128 KB Output is correct
9 Correct 25 ms 16128 KB Output is correct
10 Correct 25 ms 16128 KB Output is correct
11 Correct 25 ms 16256 KB Output is correct
12 Correct 23 ms 16128 KB Output is correct
13 Correct 24 ms 16128 KB Output is correct
14 Correct 16 ms 16256 KB Output is correct
15 Correct 19 ms 16128 KB Output is correct
16 Correct 18 ms 16128 KB Output is correct
17 Correct 22 ms 16128 KB Output is correct
18 Correct 25 ms 16128 KB Output is correct
19 Correct 25 ms 16128 KB Output is correct
20 Correct 26 ms 16128 KB Output is correct
21 Correct 26 ms 16128 KB Output is correct
22 Correct 25 ms 16128 KB Output is correct
23 Correct 26 ms 16256 KB Output is correct
24 Correct 28 ms 16128 KB Output is correct
25 Correct 22 ms 16128 KB Output is correct
26 Correct 24 ms 16128 KB Output is correct
27 Correct 70 ms 16128 KB Output is correct
28 Correct 72 ms 16128 KB Output is correct
29 Correct 75 ms 16248 KB Output is correct
30 Correct 84 ms 16128 KB Output is correct
31 Correct 76 ms 16128 KB Output is correct
32 Correct 72 ms 16128 KB Output is correct
33 Correct 63 ms 16128 KB Output is correct
34 Correct 68 ms 16128 KB Output is correct
35 Correct 63 ms 16128 KB Output is correct
36 Correct 64 ms 16128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 16256 KB Output is correct
2 Correct 22 ms 16256 KB Output is correct
3 Correct 12 ms 16128 KB Output is correct
4 Correct 22 ms 16128 KB Output is correct
5 Correct 24 ms 16256 KB Output is correct
6 Correct 22 ms 16128 KB Output is correct
7 Correct 23 ms 16128 KB Output is correct
8 Correct 24 ms 16128 KB Output is correct
9 Correct 29 ms 16128 KB Output is correct
10 Correct 25 ms 16128 KB Output is correct
11 Correct 25 ms 16128 KB Output is correct
12 Correct 23 ms 16128 KB Output is correct
13 Correct 23 ms 16128 KB Output is correct
14 Correct 17 ms 16256 KB Output is correct
15 Correct 16 ms 16128 KB Output is correct
16 Correct 19 ms 16128 KB Output is correct
17 Correct 22 ms 16128 KB Output is correct
18 Correct 22 ms 16256 KB Output is correct
19 Correct 23 ms 16128 KB Output is correct
20 Correct 26 ms 16256 KB Output is correct
21 Correct 29 ms 16256 KB Output is correct
22 Correct 26 ms 16256 KB Output is correct
23 Correct 28 ms 16128 KB Output is correct
24 Correct 26 ms 16128 KB Output is correct
25 Correct 22 ms 16128 KB Output is correct
26 Correct 23 ms 16256 KB Output is correct
27 Correct 24 ms 16128 KB Output is correct
28 Correct 28 ms 16376 KB Output is correct
29 Correct 25 ms 16128 KB Output is correct
30 Correct 29 ms 16128 KB Output is correct
31 Correct 28 ms 16128 KB Output is correct
32 Correct 28 ms 16128 KB Output is correct
33 Correct 27 ms 16128 KB Output is correct
34 Correct 25 ms 16128 KB Output is correct
35 Correct 26 ms 16128 KB Output is correct
36 Correct 28 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 16128 KB Output is correct
2 Correct 20 ms 16128 KB Output is correct
3 Correct 12 ms 16128 KB Output is correct
4 Correct 20 ms 16128 KB Output is correct
5 Correct 24 ms 16128 KB Output is correct
6 Correct 21 ms 16256 KB Output is correct
7 Correct 23 ms 16128 KB Output is correct
8 Correct 25 ms 16256 KB Output is correct
9 Correct 29 ms 16376 KB Output is correct
10 Correct 26 ms 16128 KB Output is correct
11 Correct 28 ms 16128 KB Output is correct
12 Correct 23 ms 16128 KB Output is correct
13 Correct 23 ms 16128 KB Output is correct
14 Correct 29 ms 16128 KB Output is correct
15 Correct 29 ms 16128 KB Output is correct
16 Correct 29 ms 16256 KB Output is correct
17 Correct 25 ms 16128 KB Output is correct
18 Correct 27 ms 16128 KB Output is correct
19 Correct 27 ms 16128 KB Output is correct
20 Correct 28 ms 16180 KB Output is correct
21 Correct 25 ms 16128 KB Output is correct
22 Correct 27 ms 16256 KB Output is correct
23 Correct 27 ms 16128 KB Output is correct
24 Correct 27 ms 16128 KB Output is correct
25 Correct 28 ms 16256 KB Output is correct
26 Correct 29 ms 16256 KB Output is correct
27 Correct 29 ms 16256 KB Output is correct
28 Correct 30 ms 16256 KB Output is correct
29 Correct 31 ms 16256 KB Output is correct
30 Correct 31 ms 16256 KB Output is correct
31 Correct 31 ms 16256 KB Output is correct
32 Correct 31 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 16128 KB Output is correct
2 Correct 19 ms 16152 KB Output is correct
3 Correct 13 ms 16128 KB Output is correct
4 Correct 19 ms 16128 KB Output is correct
5 Correct 21 ms 16128 KB Output is correct
6 Correct 21 ms 16128 KB Output is correct
7 Correct 23 ms 16128 KB Output is correct
8 Correct 23 ms 16128 KB Output is correct
9 Correct 25 ms 16128 KB Output is correct
10 Correct 27 ms 16256 KB Output is correct
11 Correct 25 ms 16128 KB Output is correct
12 Correct 23 ms 16128 KB Output is correct
13 Correct 23 ms 16256 KB Output is correct
14 Correct 16 ms 16128 KB Output is correct
15 Correct 19 ms 16128 KB Output is correct
16 Correct 18 ms 16128 KB Output is correct
17 Correct 23 ms 16128 KB Output is correct
18 Correct 22 ms 16128 KB Output is correct
19 Correct 24 ms 16128 KB Output is correct
20 Correct 23 ms 16256 KB Output is correct
21 Correct 23 ms 16256 KB Output is correct
22 Correct 25 ms 16128 KB Output is correct
23 Correct 27 ms 16128 KB Output is correct
24 Correct 26 ms 16256 KB Output is correct
25 Correct 22 ms 16128 KB Output is correct
26 Correct 24 ms 16128 KB Output is correct
27 Correct 68 ms 16128 KB Output is correct
28 Correct 80 ms 16128 KB Output is correct
29 Correct 83 ms 16256 KB Output is correct
30 Correct 74 ms 16128 KB Output is correct
31 Correct 76 ms 16128 KB Output is correct
32 Correct 75 ms 16128 KB Output is correct
33 Correct 62 ms 16128 KB Output is correct
34 Correct 66 ms 16128 KB Output is correct
35 Correct 62 ms 16128 KB Output is correct
36 Correct 76 ms 16236 KB Output is correct
37 Correct 23 ms 16128 KB Output is correct
38 Correct 25 ms 16128 KB Output is correct
39 Correct 28 ms 16128 KB Output is correct
40 Correct 26 ms 16256 KB Output is correct
41 Correct 26 ms 16256 KB Output is correct
42 Correct 33 ms 16128 KB Output is correct
43 Correct 31 ms 16256 KB Output is correct
44 Correct 25 ms 16128 KB Output is correct
45 Correct 27 ms 16256 KB Output is correct
46 Correct 28 ms 16256 KB Output is correct
47 Correct 31 ms 16128 KB Output is correct
48 Correct 29 ms 16256 KB Output is correct
49 Correct 29 ms 16256 KB Output is correct
50 Correct 30 ms 16256 KB Output is correct
51 Correct 30 ms 16256 KB Output is correct
52 Correct 31 ms 16256 KB Output is correct
53 Correct 31 ms 16256 KB Output is correct
54 Correct 31 ms 16256 KB Output is correct
55 Correct 33 ms 16256 KB Output is correct
56 Correct 74 ms 16256 KB Output is correct
57 Correct 75 ms 16256 KB Output is correct
58 Correct 78 ms 16256 KB Output is correct
59 Correct 79 ms 16256 KB Output is correct
60 Correct 79 ms 16256 KB Output is correct
61 Correct 93 ms 16256 KB Output is correct
62 Correct 74 ms 16256 KB Output is correct
63 Correct 88 ms 16256 KB Output is correct
64 Correct 23 ms 16256 KB Output is correct
65 Correct 75 ms 16128 KB Output is correct
66 Correct 75 ms 16248 KB Output is correct
67 Correct 78 ms 16256 KB Output is correct
68 Correct 87 ms 16256 KB Output is correct
69 Correct 85 ms 16264 KB Output is correct
70 Correct 81 ms 16176 KB Output is correct
71 Correct 90 ms 16256 KB Output is correct
72 Correct 76 ms 16256 KB Output is correct
73 Correct 73 ms 16256 KB Output is correct
74 Correct 83 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 16128 KB Output is correct
2 Correct 20 ms 16128 KB Output is correct
3 Correct 13 ms 16128 KB Output is correct
4 Correct 20 ms 16256 KB Output is correct
5 Correct 24 ms 16252 KB Output is correct
6 Correct 22 ms 16128 KB Output is correct
7 Correct 27 ms 16128 KB Output is correct
8 Correct 24 ms 16128 KB Output is correct
9 Correct 25 ms 16128 KB Output is correct
10 Correct 29 ms 16128 KB Output is correct
11 Correct 25 ms 16280 KB Output is correct
12 Correct 27 ms 16128 KB Output is correct
13 Correct 24 ms 16256 KB Output is correct
14 Correct 78 ms 16128 KB Output is correct
15 Correct 85 ms 16256 KB Output is correct
16 Correct 70 ms 16256 KB Output is correct
17 Correct 74 ms 16248 KB Output is correct
18 Correct 72 ms 16128 KB Output is correct
19 Correct 72 ms 16128 KB Output is correct
20 Correct 62 ms 16128 KB Output is correct
21 Correct 76 ms 16128 KB Output is correct
22 Correct 68 ms 16248 KB Output is correct
23 Correct 64 ms 16256 KB Output is correct
24 Correct 23 ms 16128 KB Output is correct
25 Correct 27 ms 16128 KB Output is correct
26 Correct 28 ms 16128 KB Output is correct
27 Correct 30 ms 16128 KB Output is correct
28 Correct 27 ms 16128 KB Output is correct
29 Correct 28 ms 16128 KB Output is correct
30 Correct 30 ms 16128 KB Output is correct
31 Correct 25 ms 16128 KB Output is correct
32 Correct 28 ms 16256 KB Output is correct
33 Correct 29 ms 16256 KB Output is correct
34 Correct 28 ms 16128 KB Output is correct
35 Correct 31 ms 16256 KB Output is correct
36 Correct 30 ms 16256 KB Output is correct
37 Correct 35 ms 16256 KB Output is correct
38 Correct 30 ms 16256 KB Output is correct
39 Correct 31 ms 16256 KB Output is correct
40 Correct 33 ms 16252 KB Output is correct
41 Correct 35 ms 16376 KB Output is correct
42 Correct 34 ms 16300 KB Output is correct
43 Correct 74 ms 16128 KB Output is correct
44 Correct 77 ms 16256 KB Output is correct
45 Correct 86 ms 16352 KB Output is correct
46 Correct 78 ms 16256 KB Output is correct
47 Correct 80 ms 16256 KB Output is correct
48 Correct 79 ms 16256 KB Output is correct
49 Correct 76 ms 16256 KB Output is correct
50 Correct 76 ms 16376 KB Output is correct
51 Correct 80 ms 16256 KB Output is correct
52 Correct 130 ms 17276 KB Output is correct
53 Correct 537 ms 17916 KB Output is correct
54 Correct 169 ms 18944 KB Output is correct
55 Correct 175 ms 19024 KB Output is correct
56 Execution timed out 1092 ms 27264 KB Time limit exceeded
57 Halted 0 ms 0 KB -