답안 #49403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49403 2018-05-28T10:28:27 Z okaybody10 Bali Sculptures (APIO15_sculpture) C++11
100 / 100
148 ms 2576 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2007;
ll partsum[N];
bool dp2[N][N];
int n,A,B,dp[N],bit[60];
bool solve()
{
    ll val=0;
    for(int i=0;i<44;i++) val+=bit[i]*(1LL<<i);
    if(A==1)
    {
        dp[0]=0;
        for(int i=1;i<=n;i++)
        {
            dp[i]=N;
            for(int j=0;j<i;j++)
            {
                if(((partsum[i]-partsum[j]) | val)== val) dp[i]=min(dp[i],dp[j]+1);
            }
        }
        if(dp[n]<=B) return true;
        return false;
    }
    dp2[0][0]=true;
    for(int i=1;i<=n;i++) dp2[i][0]=false;
    for(int i=1;i<=B;i++) dp2[0][i]=false;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=B;j++)
        {
                  dp2[i][j]=false;
            for(int k=0;k<i;k++)
            {
                if(dp2[k][j-1] && ((partsum[i]-partsum[k])| val) == val)  {
                    dp2[i][j]=true;
                    break;
                }
            }
        }
    }
    for(int i=A;i<=B;i++)
        if(dp2[n][i]) return true;
    return false;
}
int main()
{
    cin>>n>>A>>B;
    for(int i=1,x;i<=n;i++) cin>>x, partsum[i]=partsum[i-1]+x;
    for(int i=0;i<44;i++) bit[i]=1;
    for(int i=43;i>=0;i--)
    {
        bit[i]=0;
        bool ok=solve(); if(!ok) bit[i]=1;
    }
    ll res=0;
    for(int i=0;i<44;i++) res+=bit[i]*(1LL<<i);
    cout<<res<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 508 KB Output is correct
2 Correct 2 ms 580 KB Output is correct
3 Correct 3 ms 580 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 3 ms 616 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 3 ms 732 KB Output is correct
8 Correct 2 ms 864 KB Output is correct
9 Correct 3 ms 864 KB Output is correct
10 Correct 3 ms 864 KB Output is correct
11 Correct 2 ms 864 KB Output is correct
12 Correct 2 ms 940 KB Output is correct
13 Correct 3 ms 944 KB Output is correct
14 Correct 3 ms 944 KB Output is correct
15 Correct 3 ms 944 KB Output is correct
16 Correct 3 ms 944 KB Output is correct
17 Correct 2 ms 944 KB Output is correct
18 Correct 2 ms 944 KB Output is correct
19 Correct 3 ms 944 KB Output is correct
20 Correct 2 ms 944 KB Output is correct
21 Correct 2 ms 944 KB Output is correct
22 Correct 3 ms 944 KB Output is correct
23 Correct 2 ms 944 KB Output is correct
24 Correct 2 ms 944 KB Output is correct
25 Correct 3 ms 944 KB Output is correct
26 Correct 2 ms 1052 KB Output is correct
27 Correct 3 ms 1052 KB Output is correct
28 Correct 3 ms 1052 KB Output is correct
29 Correct 3 ms 1052 KB Output is correct
30 Correct 2 ms 1052 KB Output is correct
31 Correct 2 ms 1052 KB Output is correct
32 Correct 3 ms 1052 KB Output is correct
33 Correct 2 ms 1052 KB Output is correct
34 Correct 2 ms 1052 KB Output is correct
35 Correct 3 ms 1052 KB Output is correct
36 Correct 2 ms 1052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1052 KB Output is correct
2 Correct 3 ms 1052 KB Output is correct
3 Correct 17 ms 1052 KB Output is correct
4 Correct 2 ms 1052 KB Output is correct
5 Correct 2 ms 1052 KB Output is correct
6 Correct 2 ms 1052 KB Output is correct
7 Correct 3 ms 1052 KB Output is correct
8 Correct 2 ms 1052 KB Output is correct
9 Correct 3 ms 1052 KB Output is correct
10 Correct 3 ms 1052 KB Output is correct
11 Correct 2 ms 1052 KB Output is correct
12 Correct 2 ms 1052 KB Output is correct
13 Correct 3 ms 1052 KB Output is correct
14 Correct 3 ms 1052 KB Output is correct
15 Correct 3 ms 1052 KB Output is correct
16 Correct 3 ms 1052 KB Output is correct
17 Correct 3 ms 1052 KB Output is correct
18 Correct 3 ms 1056 KB Output is correct
19 Correct 3 ms 1060 KB Output is correct
20 Correct 3 ms 1060 KB Output is correct
21 Correct 3 ms 1068 KB Output is correct
22 Correct 3 ms 1072 KB Output is correct
23 Correct 3 ms 1076 KB Output is correct
24 Correct 4 ms 1080 KB Output is correct
25 Correct 2 ms 1088 KB Output is correct
26 Correct 3 ms 1092 KB Output is correct
27 Correct 2 ms 1092 KB Output is correct
28 Correct 3 ms 1100 KB Output is correct
29 Correct 2 ms 1104 KB Output is correct
30 Correct 3 ms 1108 KB Output is correct
31 Correct 2 ms 1112 KB Output is correct
32 Correct 3 ms 1116 KB Output is correct
33 Correct 3 ms 1120 KB Output is correct
34 Correct 2 ms 1124 KB Output is correct
35 Correct 2 ms 1160 KB Output is correct
36 Correct 2 ms 1164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1176 KB Output is correct
2 Correct 2 ms 1292 KB Output is correct
3 Correct 2 ms 1296 KB Output is correct
4 Correct 2 ms 1300 KB Output is correct
5 Correct 2 ms 1304 KB Output is correct
6 Correct 2 ms 1308 KB Output is correct
7 Correct 2 ms 1312 KB Output is correct
8 Correct 2 ms 1320 KB Output is correct
9 Correct 2 ms 1320 KB Output is correct
10 Correct 2 ms 1328 KB Output is correct
11 Correct 3 ms 1332 KB Output is correct
12 Correct 2 ms 1336 KB Output is correct
13 Correct 2 ms 1340 KB Output is correct
14 Correct 2 ms 1344 KB Output is correct
15 Correct 2 ms 1348 KB Output is correct
16 Correct 2 ms 1352 KB Output is correct
17 Correct 3 ms 1356 KB Output is correct
18 Correct 3 ms 1356 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1368 KB Output is correct
21 Correct 4 ms 1372 KB Output is correct
22 Correct 2 ms 1376 KB Output is correct
23 Correct 2 ms 1380 KB Output is correct
24 Correct 2 ms 1384 KB Output is correct
25 Correct 2 ms 1384 KB Output is correct
26 Correct 3 ms 1392 KB Output is correct
27 Correct 3 ms 1396 KB Output is correct
28 Correct 3 ms 1400 KB Output is correct
29 Correct 3 ms 1524 KB Output is correct
30 Correct 4 ms 1524 KB Output is correct
31 Correct 3 ms 1524 KB Output is correct
32 Correct 4 ms 1524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1524 KB Output is correct
2 Correct 2 ms 1524 KB Output is correct
3 Correct 2 ms 1524 KB Output is correct
4 Correct 3 ms 1524 KB Output is correct
5 Correct 2 ms 1524 KB Output is correct
6 Correct 3 ms 1524 KB Output is correct
7 Correct 2 ms 1524 KB Output is correct
8 Correct 3 ms 1524 KB Output is correct
9 Correct 3 ms 1524 KB Output is correct
10 Correct 3 ms 1524 KB Output is correct
11 Correct 3 ms 1524 KB Output is correct
12 Correct 2 ms 1524 KB Output is correct
13 Correct 2 ms 1524 KB Output is correct
14 Correct 2 ms 1524 KB Output is correct
15 Correct 2 ms 1524 KB Output is correct
16 Correct 3 ms 1524 KB Output is correct
17 Correct 2 ms 1524 KB Output is correct
18 Correct 2 ms 1524 KB Output is correct
19 Correct 3 ms 1528 KB Output is correct
20 Correct 3 ms 1532 KB Output is correct
21 Correct 2 ms 1536 KB Output is correct
22 Correct 2 ms 1540 KB Output is correct
23 Correct 3 ms 1548 KB Output is correct
24 Correct 3 ms 1552 KB Output is correct
25 Correct 2 ms 1556 KB Output is correct
26 Correct 4 ms 1560 KB Output is correct
27 Correct 2 ms 1648 KB Output is correct
28 Correct 3 ms 1648 KB Output is correct
29 Correct 2 ms 1648 KB Output is correct
30 Correct 2 ms 1648 KB Output is correct
31 Correct 2 ms 1648 KB Output is correct
32 Correct 2 ms 1648 KB Output is correct
33 Correct 3 ms 1648 KB Output is correct
34 Correct 2 ms 1648 KB Output is correct
35 Correct 2 ms 1648 KB Output is correct
36 Correct 2 ms 1648 KB Output is correct
37 Correct 2 ms 1648 KB Output is correct
38 Correct 2 ms 1648 KB Output is correct
39 Correct 3 ms 1736 KB Output is correct
40 Correct 2 ms 1736 KB Output is correct
41 Correct 2 ms 1736 KB Output is correct
42 Correct 3 ms 1736 KB Output is correct
43 Correct 2 ms 1736 KB Output is correct
44 Correct 3 ms 1736 KB Output is correct
45 Correct 2 ms 1736 KB Output is correct
46 Correct 2 ms 1736 KB Output is correct
47 Correct 3 ms 1736 KB Output is correct
48 Correct 2 ms 1736 KB Output is correct
49 Correct 3 ms 1736 KB Output is correct
50 Correct 3 ms 1736 KB Output is correct
51 Correct 3 ms 1736 KB Output is correct
52 Correct 3 ms 1736 KB Output is correct
53 Correct 3 ms 1736 KB Output is correct
54 Correct 4 ms 1736 KB Output is correct
55 Correct 3 ms 1804 KB Output is correct
56 Correct 2 ms 1804 KB Output is correct
57 Correct 3 ms 1808 KB Output is correct
58 Correct 3 ms 1808 KB Output is correct
59 Correct 3 ms 1808 KB Output is correct
60 Correct 4 ms 1808 KB Output is correct
61 Correct 3 ms 1808 KB Output is correct
62 Correct 4 ms 1840 KB Output is correct
63 Correct 3 ms 1840 KB Output is correct
64 Correct 21 ms 1884 KB Output is correct
65 Correct 5 ms 1884 KB Output is correct
66 Correct 5 ms 1888 KB Output is correct
67 Correct 8 ms 1892 KB Output is correct
68 Correct 16 ms 1948 KB Output is correct
69 Correct 28 ms 1948 KB Output is correct
70 Correct 43 ms 2032 KB Output is correct
71 Correct 3 ms 2032 KB Output is correct
72 Correct 32 ms 2032 KB Output is correct
73 Correct 23 ms 2032 KB Output is correct
74 Correct 22 ms 2032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2032 KB Output is correct
2 Correct 3 ms 2032 KB Output is correct
3 Correct 2 ms 2032 KB Output is correct
4 Correct 2 ms 2032 KB Output is correct
5 Correct 2 ms 2032 KB Output is correct
6 Correct 3 ms 2032 KB Output is correct
7 Correct 2 ms 2032 KB Output is correct
8 Correct 2 ms 2032 KB Output is correct
9 Correct 2 ms 2032 KB Output is correct
10 Correct 2 ms 2032 KB Output is correct
11 Correct 4 ms 2032 KB Output is correct
12 Correct 3 ms 2032 KB Output is correct
13 Correct 2 ms 2032 KB Output is correct
14 Correct 3 ms 2032 KB Output is correct
15 Correct 3 ms 2032 KB Output is correct
16 Correct 3 ms 2032 KB Output is correct
17 Correct 2 ms 2032 KB Output is correct
18 Correct 3 ms 2032 KB Output is correct
19 Correct 3 ms 2032 KB Output is correct
20 Correct 2 ms 2032 KB Output is correct
21 Correct 3 ms 2032 KB Output is correct
22 Correct 3 ms 2032 KB Output is correct
23 Correct 3 ms 2032 KB Output is correct
24 Correct 2 ms 2032 KB Output is correct
25 Correct 2 ms 2032 KB Output is correct
26 Correct 3 ms 2032 KB Output is correct
27 Correct 2 ms 2032 KB Output is correct
28 Correct 2 ms 2032 KB Output is correct
29 Correct 2 ms 2032 KB Output is correct
30 Correct 2 ms 2032 KB Output is correct
31 Correct 2 ms 2032 KB Output is correct
32 Correct 2 ms 2032 KB Output is correct
33 Correct 2 ms 2032 KB Output is correct
34 Correct 3 ms 2032 KB Output is correct
35 Correct 2 ms 2032 KB Output is correct
36 Correct 3 ms 2032 KB Output is correct
37 Correct 3 ms 2032 KB Output is correct
38 Correct 3 ms 2032 KB Output is correct
39 Correct 4 ms 2032 KB Output is correct
40 Correct 3 ms 2032 KB Output is correct
41 Correct 4 ms 2032 KB Output is correct
42 Correct 3 ms 2032 KB Output is correct
43 Correct 3 ms 2032 KB Output is correct
44 Correct 3 ms 2032 KB Output is correct
45 Correct 3 ms 2032 KB Output is correct
46 Correct 3 ms 2032 KB Output is correct
47 Correct 2 ms 2032 KB Output is correct
48 Correct 3 ms 2152 KB Output is correct
49 Correct 3 ms 2152 KB Output is correct
50 Correct 4 ms 2152 KB Output is correct
51 Correct 3 ms 2184 KB Output is correct
52 Correct 13 ms 2184 KB Output is correct
53 Correct 20 ms 2184 KB Output is correct
54 Correct 36 ms 2232 KB Output is correct
55 Correct 35 ms 2232 KB Output is correct
56 Correct 116 ms 2232 KB Output is correct
57 Correct 120 ms 2260 KB Output is correct
58 Correct 108 ms 2260 KB Output is correct
59 Correct 148 ms 2260 KB Output is correct
60 Correct 133 ms 2460 KB Output is correct
61 Correct 3 ms 2460 KB Output is correct
62 Correct 23 ms 2460 KB Output is correct
63 Correct 35 ms 2488 KB Output is correct
64 Correct 31 ms 2488 KB Output is correct
65 Correct 63 ms 2488 KB Output is correct
66 Correct 86 ms 2488 KB Output is correct
67 Correct 108 ms 2488 KB Output is correct
68 Correct 119 ms 2576 KB Output is correct
69 Correct 148 ms 2576 KB Output is correct