답안 #91550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91550 2018-12-28T10:16:30 Z Bodo171 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
183 ms 1116 KB
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=2005;
long long v[nmax];
int best[nmax];
bool dp[105][105];
long long sum,frb,ans;
int n,i,j,k,a,b;
bool chk_brt(long long val)
{
    dp[0][0]=1;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
           dp[i][j]=0;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
    {
        sum=0;
        for(k=j;k>=1;k--)
        {
            sum+=v[k];
            if((sum&frb)==0)
                dp[i][j]|=dp[i-1][k-1];
        }
        if(i>=a&&i<=b&&dp[i][n])
            return 1;
    }
    return 0;
}
bool chk_smen()
{
    best[0]=0;
    for(i=1;i<=n;i++)
        best[i]=n+1;
    for(i=1;i<=n;i++)
    {
        sum=0;
        for(j=i;j>=1;j--)
        {
            sum+=v[j];
            if((sum&frb)==0)
                best[i]=min(best[i],best[j-1]+1);
        }
    }
    return (best[n]<=b);
}
bool check(long long val)
{
    frb=(((1LL<<61)-1)^val);
    if(n<=100) return chk_brt(val);
    return chk_smen();
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
        cin>>v[i];
    ans=(1LL<<61)-1;
    for(long long p=60;p>=0;p--)
        if(check(ans-(1LL<<p)))
          ans-=(1LL<<p);
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 480 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 2 ms 508 KB Output is correct
10 Correct 2 ms 552 KB Output is correct
11 Correct 2 ms 552 KB Output is correct
12 Correct 1 ms 552 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 572 KB Output is correct
15 Correct 2 ms 572 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 2 ms 572 KB Output is correct
18 Correct 2 ms 572 KB Output is correct
19 Correct 2 ms 572 KB Output is correct
20 Correct 2 ms 580 KB Output is correct
21 Correct 2 ms 580 KB Output is correct
22 Correct 2 ms 580 KB Output is correct
23 Correct 2 ms 580 KB Output is correct
24 Correct 2 ms 580 KB Output is correct
25 Correct 2 ms 580 KB Output is correct
26 Correct 2 ms 580 KB Output is correct
27 Correct 1 ms 580 KB Output is correct
28 Correct 2 ms 580 KB Output is correct
29 Correct 2 ms 592 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 2 ms 608 KB Output is correct
34 Correct 2 ms 608 KB Output is correct
35 Correct 2 ms 608 KB Output is correct
36 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 2 ms 608 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 2 ms 608 KB Output is correct
13 Correct 2 ms 608 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 2 ms 608 KB Output is correct
17 Correct 2 ms 608 KB Output is correct
18 Correct 2 ms 608 KB Output is correct
19 Correct 2 ms 608 KB Output is correct
20 Correct 2 ms 608 KB Output is correct
21 Correct 2 ms 608 KB Output is correct
22 Correct 2 ms 608 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 608 KB Output is correct
25 Correct 2 ms 608 KB Output is correct
26 Correct 2 ms 608 KB Output is correct
27 Correct 2 ms 608 KB Output is correct
28 Correct 2 ms 608 KB Output is correct
29 Correct 2 ms 608 KB Output is correct
30 Correct 2 ms 608 KB Output is correct
31 Correct 2 ms 608 KB Output is correct
32 Correct 2 ms 608 KB Output is correct
33 Correct 2 ms 608 KB Output is correct
34 Correct 2 ms 608 KB Output is correct
35 Correct 2 ms 608 KB Output is correct
36 Correct 3 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 2 ms 608 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 2 ms 608 KB Output is correct
13 Correct 2 ms 608 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 2 ms 608 KB Output is correct
17 Correct 3 ms 624 KB Output is correct
18 Correct 2 ms 624 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 2 ms 636 KB Output is correct
21 Correct 2 ms 636 KB Output is correct
22 Correct 3 ms 636 KB Output is correct
23 Correct 2 ms 636 KB Output is correct
24 Correct 3 ms 636 KB Output is correct
25 Correct 3 ms 636 KB Output is correct
26 Correct 4 ms 636 KB Output is correct
27 Correct 5 ms 636 KB Output is correct
28 Correct 6 ms 636 KB Output is correct
29 Correct 6 ms 636 KB Output is correct
30 Correct 8 ms 756 KB Output is correct
31 Correct 6 ms 756 KB Output is correct
32 Correct 6 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 756 KB Output is correct
2 Correct 2 ms 756 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 2 ms 756 KB Output is correct
5 Correct 2 ms 756 KB Output is correct
6 Correct 2 ms 756 KB Output is correct
7 Correct 2 ms 756 KB Output is correct
8 Correct 2 ms 756 KB Output is correct
9 Correct 2 ms 756 KB Output is correct
10 Correct 2 ms 756 KB Output is correct
11 Correct 2 ms 756 KB Output is correct
12 Correct 2 ms 756 KB Output is correct
13 Correct 2 ms 756 KB Output is correct
14 Correct 2 ms 756 KB Output is correct
15 Correct 2 ms 756 KB Output is correct
16 Correct 2 ms 756 KB Output is correct
17 Correct 2 ms 756 KB Output is correct
18 Correct 2 ms 756 KB Output is correct
19 Correct 2 ms 756 KB Output is correct
20 Correct 2 ms 756 KB Output is correct
21 Correct 2 ms 756 KB Output is correct
22 Correct 2 ms 756 KB Output is correct
23 Correct 2 ms 756 KB Output is correct
24 Correct 2 ms 756 KB Output is correct
25 Correct 2 ms 756 KB Output is correct
26 Correct 2 ms 756 KB Output is correct
27 Correct 2 ms 756 KB Output is correct
28 Correct 2 ms 756 KB Output is correct
29 Correct 2 ms 756 KB Output is correct
30 Correct 2 ms 756 KB Output is correct
31 Correct 2 ms 756 KB Output is correct
32 Correct 2 ms 756 KB Output is correct
33 Correct 2 ms 756 KB Output is correct
34 Correct 2 ms 756 KB Output is correct
35 Correct 2 ms 756 KB Output is correct
36 Correct 2 ms 756 KB Output is correct
37 Correct 2 ms 756 KB Output is correct
38 Correct 2 ms 756 KB Output is correct
39 Correct 2 ms 756 KB Output is correct
40 Correct 2 ms 756 KB Output is correct
41 Correct 2 ms 756 KB Output is correct
42 Correct 2 ms 756 KB Output is correct
43 Correct 2 ms 756 KB Output is correct
44 Correct 2 ms 756 KB Output is correct
45 Correct 2 ms 756 KB Output is correct
46 Correct 2 ms 756 KB Output is correct
47 Correct 2 ms 756 KB Output is correct
48 Correct 3 ms 756 KB Output is correct
49 Correct 4 ms 756 KB Output is correct
50 Correct 5 ms 756 KB Output is correct
51 Correct 6 ms 756 KB Output is correct
52 Correct 6 ms 756 KB Output is correct
53 Correct 7 ms 756 KB Output is correct
54 Correct 6 ms 756 KB Output is correct
55 Correct 6 ms 756 KB Output is correct
56 Correct 5 ms 756 KB Output is correct
57 Correct 11 ms 756 KB Output is correct
58 Correct 15 ms 756 KB Output is correct
59 Correct 19 ms 756 KB Output is correct
60 Correct 19 ms 756 KB Output is correct
61 Correct 14 ms 756 KB Output is correct
62 Correct 19 ms 756 KB Output is correct
63 Correct 18 ms 756 KB Output is correct
64 Correct 21 ms 756 KB Output is correct
65 Correct 5 ms 756 KB Output is correct
66 Correct 7 ms 756 KB Output is correct
67 Correct 10 ms 756 KB Output is correct
68 Correct 19 ms 756 KB Output is correct
69 Correct 33 ms 756 KB Output is correct
70 Correct 32 ms 756 KB Output is correct
71 Correct 13 ms 756 KB Output is correct
72 Correct 19 ms 756 KB Output is correct
73 Correct 31 ms 756 KB Output is correct
74 Correct 27 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 756 KB Output is correct
2 Correct 2 ms 756 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 2 ms 756 KB Output is correct
5 Correct 2 ms 756 KB Output is correct
6 Correct 2 ms 756 KB Output is correct
7 Correct 2 ms 756 KB Output is correct
8 Correct 2 ms 756 KB Output is correct
9 Correct 2 ms 756 KB Output is correct
10 Correct 3 ms 756 KB Output is correct
11 Correct 3 ms 756 KB Output is correct
12 Correct 2 ms 756 KB Output is correct
13 Correct 2 ms 756 KB Output is correct
14 Correct 2 ms 756 KB Output is correct
15 Correct 2 ms 756 KB Output is correct
16 Correct 2 ms 756 KB Output is correct
17 Correct 2 ms 756 KB Output is correct
18 Correct 2 ms 756 KB Output is correct
19 Correct 2 ms 756 KB Output is correct
20 Correct 2 ms 756 KB Output is correct
21 Correct 2 ms 756 KB Output is correct
22 Correct 2 ms 756 KB Output is correct
23 Correct 2 ms 756 KB Output is correct
24 Correct 2 ms 756 KB Output is correct
25 Correct 2 ms 756 KB Output is correct
26 Correct 2 ms 756 KB Output is correct
27 Correct 2 ms 756 KB Output is correct
28 Correct 2 ms 756 KB Output is correct
29 Correct 2 ms 756 KB Output is correct
30 Correct 2 ms 760 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 2 ms 760 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 3 ms 760 KB Output is correct
35 Correct 3 ms 760 KB Output is correct
36 Correct 4 ms 760 KB Output is correct
37 Correct 5 ms 760 KB Output is correct
38 Correct 6 ms 760 KB Output is correct
39 Correct 6 ms 760 KB Output is correct
40 Correct 8 ms 760 KB Output is correct
41 Correct 6 ms 760 KB Output is correct
42 Correct 6 ms 760 KB Output is correct
43 Correct 5 ms 760 KB Output is correct
44 Correct 11 ms 760 KB Output is correct
45 Correct 15 ms 760 KB Output is correct
46 Correct 19 ms 760 KB Output is correct
47 Correct 18 ms 760 KB Output is correct
48 Correct 12 ms 760 KB Output is correct
49 Correct 18 ms 760 KB Output is correct
50 Correct 18 ms 760 KB Output is correct
51 Correct 2 ms 760 KB Output is correct
52 Correct 18 ms 760 KB Output is correct
53 Correct 28 ms 760 KB Output is correct
54 Correct 55 ms 760 KB Output is correct
55 Correct 50 ms 760 KB Output is correct
56 Correct 182 ms 788 KB Output is correct
57 Correct 181 ms 824 KB Output is correct
58 Correct 175 ms 968 KB Output is correct
59 Correct 175 ms 968 KB Output is correct
60 Correct 183 ms 968 KB Output is correct
61 Correct 2 ms 968 KB Output is correct
62 Correct 28 ms 968 KB Output is correct
63 Correct 57 ms 968 KB Output is correct
64 Correct 49 ms 968 KB Output is correct
65 Correct 94 ms 980 KB Output is correct
66 Correct 143 ms 1096 KB Output is correct
67 Correct 179 ms 1116 KB Output is correct
68 Correct 180 ms 1116 KB Output is correct
69 Correct 179 ms 1116 KB Output is correct