답안 #113199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113199 2019-05-24T09:23:15 Z ansol4328 Bali Sculptures (APIO15_sculpture) C++11
100 / 100
91 ms 768 KB
#include<stdio.h>
#include<algorithm>

using namespace std;
typedef long long ll;

int n, a, b;
ll m[2005], s[2005];
int dp[2005][2005];
const int INF=1e9;

int main()
{
    scanf("%d %d %d",&n,&a,&b);
    for(int i=1 ; i<=n ; i++)
    {
        scanf("%lld",&m[i]);
        s[i]=s[i-1]+m[i];
    }
    ll res=1, idx=1;
    while(res<s[n]) idx<<=1, (res<<=1)+=1;
    if(a==1)
    {
        while(idx!=0)
        {
            for(int i=1 ; i<=n ; i++) dp[1][i]=INF;
            (res&=~idx);
            for(int i=1 ; i<=n ; i++)
            {
                for(int j=i-1 ; j>=0 ; j--)
                {
                    if((res|(s[i]-s[j]))==res) dp[1][i]=min(dp[1][i],dp[1][j]+1);
                }
            }
            if(dp[1][n]>b) res|=idx;
            idx>>=1;
        }
    }
    else
    {
        while(idx!=0)
        {
            bool tf=false;
            (res&=~idx);
            for(int i=1 ; i<=n ; i++)
            {
                dp[1][i]=INF;
                if((s[i]|res)==res) dp[1][i]=1;
            }
            for(int k=2 ; k<=b ; k++)
            {
                for(int i=k ; i<=n ; i++)
                {
                    dp[k][i]=INF;
                    for(int j=i-1 ; j>=k-1 ; j--)
                    {
                        if((res|(s[i]-s[j]))==res && dp[k-1][j]==k-1) dp[k][i]=k;
                    }
                }
                if(k>=a && dp[k][n]!=INF)
                {
                    tf=true;
                    break;
                }
            }
            if(!tf) res|=idx;
            idx>>=1;
        }
    }
    printf("%lld",res);
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:14: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:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&m[i]);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 256 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 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 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 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 384 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 1 ms 256 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 1 ms 256 KB Output is correct
36 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 384 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 384 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 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 2 ms 432 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 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 384 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 2 ms 256 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 256 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 256 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
59 Correct 2 ms 384 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 2 ms 384 KB Output is correct
62 Correct 2 ms 256 KB Output is correct
63 Correct 2 ms 384 KB Output is correct
64 Correct 3 ms 640 KB Output is correct
65 Correct 3 ms 384 KB Output is correct
66 Correct 3 ms 384 KB Output is correct
67 Correct 4 ms 384 KB Output is correct
68 Correct 7 ms 512 KB Output is correct
69 Correct 9 ms 768 KB Output is correct
70 Correct 9 ms 768 KB Output is correct
71 Correct 2 ms 256 KB Output is correct
72 Correct 10 ms 768 KB Output is correct
73 Correct 12 ms 640 KB Output is correct
74 Correct 10 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 1 ms 256 KB Output is correct
40 Correct 2 ms 256 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 256 KB Output is correct
45 Correct 2 ms 256 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 256 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 8 ms 384 KB Output is correct
53 Correct 11 ms 384 KB Output is correct
54 Correct 20 ms 384 KB Output is correct
55 Correct 19 ms 384 KB Output is correct
56 Correct 70 ms 384 KB Output is correct
57 Correct 68 ms 384 KB Output is correct
58 Correct 75 ms 384 KB Output is correct
59 Correct 91 ms 504 KB Output is correct
60 Correct 90 ms 504 KB Output is correct
61 Correct 2 ms 256 KB Output is correct
62 Correct 13 ms 256 KB Output is correct
63 Correct 22 ms 384 KB Output is correct
64 Correct 21 ms 384 KB Output is correct
65 Correct 41 ms 384 KB Output is correct
66 Correct 59 ms 504 KB Output is correct
67 Correct 79 ms 384 KB Output is correct
68 Correct 82 ms 504 KB Output is correct
69 Correct 83 ms 384 KB Output is correct