답안 #145986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145986 2019-08-21T13:46:36 Z mhy908 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
180 ms 524 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, a, b;
LL arr[2010], sum[2010];
int dp[2010];
bool ch[110][110];
bool poss(LL num)
{
    if(a==1){
        for(int i=1; i<=n; i++){
            dp[i]=b+1;
            for(int j=1; j<=i; j++){
                LL t=sum[i]-sum[j-1];
                if((t&(~num))==0){
                    dp[i]=min(dp[i], dp[j-1]+1);
                }
            }
        }
        return dp[n]<=b;
    }
    else{
        memset(ch, 0, sizeof(ch));
        ch[0][0]=true;
        for(int i=1; i<=n; i++){
            for(int j=1; j<=i; j++){
                for(int k=1; k<=i; k++){
                    LL t=sum[i]-sum[k-1];
                    if(ch[k-1][j-1]&&((t&(~num))==0)){
                        ch[i][j]=true;
                    }
                }
            }
        }
        for(int i=a; i<=b; i++){
            if(ch[n][i])return true;
        }
        return false;
    }
}
int main()
{
    scanf("%d %d %d", &n, &a, &b);
    for(int i=1; i<=n; i++){
        scanf("%lld", &arr[i]);
        sum[i]=sum[i-1]+arr[i];
    }
    LL ans=(1LL<<55)-1LL;
    for(int i=54; i>=0; i--){
        LL temp=(1LL<<i);
        if(poss(ans&(~temp)))ans&=(~temp);
    }
    printf("%lld", ans);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 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 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 252 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 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 252 KB Output is correct
13 Correct 2 ms 256 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 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 424 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 292 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 256 KB Output is correct
31 Correct 3 ms 252 KB Output is correct
32 Correct 3 ms 256 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 256 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 348 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 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 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 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 3 ms 376 KB Output is correct
22 Correct 2 ms 392 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 396 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 380 KB Output is correct
34 Correct 2 ms 356 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 0 ms 252 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 256 KB Output is correct
39 Correct 2 ms 356 KB Output is correct
40 Correct 2 ms 328 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 252 KB Output is correct
43 Correct 2 ms 296 KB Output is correct
44 Correct 3 ms 376 KB Output is correct
45 Correct 2 ms 392 KB Output is correct
46 Correct 2 ms 524 KB Output is correct
47 Correct 2 ms 380 KB Output is correct
48 Correct 2 ms 256 KB Output is correct
49 Correct 2 ms 372 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 3 ms 392 KB Output is correct
52 Correct 3 ms 376 KB Output is correct
53 Correct 3 ms 360 KB Output is correct
54 Correct 3 ms 360 KB Output is correct
55 Correct 3 ms 376 KB Output is correct
56 Correct 2 ms 376 KB Output is correct
57 Correct 2 ms 376 KB Output is correct
58 Correct 2 ms 256 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 252 KB Output is correct
61 Correct 2 ms 256 KB Output is correct
62 Correct 3 ms 376 KB Output is correct
63 Correct 3 ms 372 KB Output is correct
64 Correct 21 ms 348 KB Output is correct
65 Correct 8 ms 376 KB Output is correct
66 Correct 10 ms 376 KB Output is correct
67 Correct 13 ms 356 KB Output is correct
68 Correct 20 ms 464 KB Output is correct
69 Correct 24 ms 376 KB Output is correct
70 Correct 25 ms 416 KB Output is correct
71 Correct 25 ms 376 KB Output is correct
72 Correct 25 ms 376 KB Output is correct
73 Correct 25 ms 376 KB Output is correct
74 Correct 25 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 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 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 252 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 252 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 296 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 2 ms 256 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 3 ms 376 KB Output is correct
39 Correct 3 ms 256 KB Output is correct
40 Correct 3 ms 256 KB Output is correct
41 Correct 3 ms 256 KB Output is correct
42 Correct 3 ms 256 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 256 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 256 KB Output is correct
47 Correct 2 ms 256 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 256 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 18 ms 376 KB Output is correct
53 Correct 27 ms 376 KB Output is correct
54 Correct 50 ms 404 KB Output is correct
55 Correct 49 ms 388 KB Output is correct
56 Correct 180 ms 396 KB Output is correct
57 Correct 176 ms 396 KB Output is correct
58 Correct 172 ms 476 KB Output is correct
59 Correct 171 ms 504 KB Output is correct
60 Correct 178 ms 476 KB Output is correct
61 Correct 3 ms 376 KB Output is correct
62 Correct 28 ms 376 KB Output is correct
63 Correct 49 ms 376 KB Output is correct
64 Correct 47 ms 420 KB Output is correct
65 Correct 89 ms 436 KB Output is correct
66 Correct 134 ms 376 KB Output is correct
67 Correct 176 ms 504 KB Output is correct
68 Correct 178 ms 376 KB Output is correct
69 Correct 177 ms 432 KB Output is correct