답안 #386693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
386693 2021-04-07T08:22:14 Z jjang36524 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
123 ms 512 KB
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
#define int long long
int dp[2001];
int dp2[101][101];
int psum[2001];
signed main()
{
    int N,a,b;
    cin >> N >> a >> b;
    int i;
    for(i=0;i<N;i++)
    {
        int v;
        cin >> v;
        psum[i+1]=psum[i]+v;
    }
    if(a==1)
    {
        int cu=(1LL<<42)-1;
        for(i=41;i>=0;i--)
        {
            cu-=1LL<<i;
            int j;
            memset(dp,1,sizeof(dp));
            dp[0]=0;
            for(j=1;j<=N;j++)
            {
                int k;
                for(k=0;k<j;k++)
                {
                    if(((psum[j]-psum[k])|cu)==cu)
                    {
                        dp[j]=min(dp[j],dp[k]+1);
                    }
                }
            }
            if(dp[N]>b)
                cu+=1LL<<i;
        }
        cout <<cu;
    }
    else
    {
        int cu=(1LL<<42)-1;
        for(i=41;i>=0;i--)
        {
            cu-=1LL<<i;
            int j;
            memset(dp2,0,sizeof(dp2));
            dp2[0][0]=1;
            for(j=1;j<=N;j++)
            {
                int k;
                for(k=0;k<j;k++)
                {
                    if(((psum[j]-psum[k])|cu)==cu)
                    {
                        int l;
                        for(l=0;l<N;l++)
                        {
                            dp2[j][l+1]|=dp2[k][l];
                        }
                    }
                }
            }
            int po=0;
            for(j=a;j<=b;j++)
            {
                po|=dp2[N][j];
            }
             if(!po)
                cu+=1LL<<i;
        }
        cout <<cu;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 2 ms 496 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Correct 1 ms 364 KB Output is correct
43 Correct 1 ms 364 KB Output is correct
44 Correct 2 ms 364 KB Output is correct
45 Correct 1 ms 364 KB Output is correct
46 Correct 1 ms 364 KB Output is correct
47 Correct 1 ms 364 KB Output is correct
48 Correct 1 ms 364 KB Output is correct
49 Correct 2 ms 364 KB Output is correct
50 Correct 2 ms 364 KB Output is correct
51 Correct 2 ms 364 KB Output is correct
52 Correct 3 ms 364 KB Output is correct
53 Correct 2 ms 364 KB Output is correct
54 Correct 2 ms 364 KB Output is correct
55 Correct 2 ms 364 KB Output is correct
56 Correct 1 ms 364 KB Output is correct
57 Correct 1 ms 364 KB Output is correct
58 Correct 2 ms 364 KB Output is correct
59 Correct 2 ms 364 KB Output is correct
60 Correct 2 ms 364 KB Output is correct
61 Correct 2 ms 364 KB Output is correct
62 Correct 2 ms 364 KB Output is correct
63 Correct 2 ms 364 KB Output is correct
64 Correct 19 ms 364 KB Output is correct
65 Correct 3 ms 364 KB Output is correct
66 Correct 4 ms 364 KB Output is correct
67 Correct 4 ms 364 KB Output is correct
68 Correct 8 ms 364 KB Output is correct
69 Correct 6 ms 364 KB Output is correct
70 Correct 6 ms 364 KB Output is correct
71 Correct 6 ms 364 KB Output is correct
72 Correct 8 ms 364 KB Output is correct
73 Correct 8 ms 364 KB Output is correct
74 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 376 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 2 ms 364 KB Output is correct
38 Correct 2 ms 364 KB Output is correct
39 Correct 2 ms 364 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 2 ms 364 KB Output is correct
42 Correct 2 ms 364 KB Output is correct
43 Correct 1 ms 364 KB Output is correct
44 Correct 2 ms 364 KB Output is correct
45 Correct 2 ms 364 KB Output is correct
46 Correct 2 ms 492 KB Output is correct
47 Correct 2 ms 364 KB Output is correct
48 Correct 2 ms 364 KB Output is correct
49 Correct 2 ms 364 KB Output is correct
50 Correct 2 ms 364 KB Output is correct
51 Correct 2 ms 364 KB Output is correct
52 Correct 11 ms 364 KB Output is correct
53 Correct 17 ms 364 KB Output is correct
54 Correct 31 ms 364 KB Output is correct
55 Correct 29 ms 364 KB Output is correct
56 Correct 123 ms 492 KB Output is correct
57 Correct 111 ms 364 KB Output is correct
58 Correct 103 ms 492 KB Output is correct
59 Correct 99 ms 364 KB Output is correct
60 Correct 114 ms 364 KB Output is correct
61 Correct 2 ms 364 KB Output is correct
62 Correct 17 ms 364 KB Output is correct
63 Correct 53 ms 364 KB Output is correct
64 Correct 50 ms 364 KB Output is correct
65 Correct 52 ms 364 KB Output is correct
66 Correct 94 ms 420 KB Output is correct
67 Correct 103 ms 364 KB Output is correct
68 Correct 123 ms 492 KB Output is correct
69 Correct 100 ms 364 KB Output is correct