# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
74722 | 2018-09-07T03:05:44 Z | goodbaton | Bali Sculptures (APIO15_sculpture) | C++14 | 40 ms | 2208 KB |
#include <cstdio> #include <cstdlib> #include <vector> #include <set> #include <algorithm> #include <map> #include <queue> #include <stack> #include <cmath> using namespace std; typedef long long ll; #define SIZE 2000 #define INF 2000000000 #define LLINF 4000000000000000000LL int N,A,B; bool dp[SIZE+1][SIZE]; int dp5[SIZE+1]; ll Y[SIZE+1]; ll dfs5(int h,ll ksum){ if(h<0) return ksum; ll ksumaf = ksum - (1LL<<h); for(int i=0;i<=N;i++) dp5[i]=INF; dp5[0]=0; for(int i=0;i<N;i++){ if(dp5[i]==INF) continue; for(int j=i+1;j<=N;j++){ if(Y[j]-Y[i] > ksumaf) break; if(((Y[j]-Y[i]) | ksumaf) == ksumaf) dp5[j]=min(dp5[j],dp5[i]+1); } } if(dp5[N]<=B) return dfs5(h-1,ksumaf); return dfs5(h-1,ksum); } ll dfs(int h,ll ksum){ if(h<0) return ksum; ll ksumaf = ksum - (1LL<<h); for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) dp[i][j]=false; dp[0][0]=true; for(int k=0;k<B;k++){ for(int i=0;i<N;i++){ if(dp[k][i]==false) continue; for(int j=i+1;j<=N;j++){ if(Y[j]-Y[i] > ksumaf) break; if(((Y[j]-Y[i]) | ksumaf) == ksumaf) dp[k+1][j]=true; } } } for(int i=A;i<=B;i++){ if(dp[i][N]==true) return dfs(h-1,ksumaf); } return dfs(h-1,ksum); } int main(){ int b=0; //b2 = 2^b ll b2; scanf("%d%d%d",&N,&A,&B); for(int i=1;i<=N;i++){ scanf("%lld",&Y[i]); Y[i]+=Y[i-1]; } for(b2=1;b2<=Y[N];b2*=2) b++; if(A==1) printf("%lld\n",dfs5(b-1,b2-1)); else printf("%lld\n",dfs(b-1,b2-1)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 636 KB | Output is correct |
8 | Correct | 2 ms | 636 KB | Output is correct |
9 | Correct | 2 ms | 704 KB | Output is correct |
10 | Correct | 2 ms | 704 KB | Output is correct |
11 | Correct | 2 ms | 704 KB | Output is correct |
12 | Correct | 2 ms | 704 KB | Output is correct |
13 | Correct | 2 ms | 704 KB | Output is correct |
14 | Correct | 2 ms | 704 KB | Output is correct |
15 | Correct | 2 ms | 744 KB | Output is correct |
16 | Correct | 2 ms | 748 KB | Output is correct |
17 | Correct | 2 ms | 792 KB | Output is correct |
18 | Correct | 2 ms | 792 KB | Output is correct |
19 | Correct | 2 ms | 804 KB | Output is correct |
20 | Correct | 2 ms | 808 KB | Output is correct |
21 | Correct | 2 ms | 812 KB | Output is correct |
22 | Correct | 2 ms | 816 KB | Output is correct |
23 | Correct | 2 ms | 820 KB | Output is correct |
24 | Correct | 2 ms | 824 KB | Output is correct |
25 | Correct | 3 ms | 832 KB | Output is correct |
26 | Correct | 2 ms | 836 KB | Output is correct |
27 | Correct | 2 ms | 836 KB | Output is correct |
28 | Correct | 2 ms | 836 KB | Output is correct |
29 | Correct | 2 ms | 836 KB | Output is correct |
30 | Correct | 2 ms | 836 KB | Output is correct |
31 | Correct | 2 ms | 836 KB | Output is correct |
32 | Correct | 2 ms | 836 KB | Output is correct |
33 | Correct | 2 ms | 836 KB | Output is correct |
34 | Correct | 2 ms | 836 KB | Output is correct |
35 | Correct | 2 ms | 976 KB | Output is correct |
36 | Correct | 2 ms | 976 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 976 KB | Output is correct |
2 | Correct | 2 ms | 976 KB | Output is correct |
3 | Correct | 2 ms | 976 KB | Output is correct |
4 | Correct | 2 ms | 976 KB | Output is correct |
5 | Correct | 2 ms | 976 KB | Output is correct |
6 | Correct | 2 ms | 976 KB | Output is correct |
7 | Correct | 2 ms | 976 KB | Output is correct |
8 | Correct | 2 ms | 976 KB | Output is correct |
9 | Correct | 2 ms | 976 KB | Output is correct |
10 | Correct | 2 ms | 976 KB | Output is correct |
11 | Correct | 2 ms | 976 KB | Output is correct |
12 | Correct | 2 ms | 976 KB | Output is correct |
13 | Correct | 2 ms | 976 KB | Output is correct |
14 | Correct | 2 ms | 976 KB | Output is correct |
15 | Correct | 2 ms | 976 KB | Output is correct |
16 | Correct | 2 ms | 976 KB | Output is correct |
17 | Correct | 2 ms | 976 KB | Output is correct |
18 | Correct | 2 ms | 976 KB | Output is correct |
19 | Correct | 2 ms | 976 KB | Output is correct |
20 | Correct | 2 ms | 976 KB | Output is correct |
21 | Correct | 2 ms | 976 KB | Output is correct |
22 | Correct | 2 ms | 976 KB | Output is correct |
23 | Correct | 2 ms | 976 KB | Output is correct |
24 | Correct | 2 ms | 976 KB | Output is correct |
25 | Correct | 2 ms | 980 KB | Output is correct |
26 | Correct | 2 ms | 984 KB | Output is correct |
27 | Correct | 2 ms | 984 KB | Output is correct |
28 | Correct | 2 ms | 984 KB | Output is correct |
29 | Correct | 2 ms | 984 KB | Output is correct |
30 | Correct | 2 ms | 984 KB | Output is correct |
31 | Correct | 2 ms | 984 KB | Output is correct |
32 | Correct | 2 ms | 984 KB | Output is correct |
33 | Correct | 2 ms | 984 KB | Output is correct |
34 | Correct | 2 ms | 984 KB | Output is correct |
35 | Correct | 2 ms | 984 KB | Output is correct |
36 | Correct | 2 ms | 984 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 984 KB | Output is correct |
2 | Correct | 2 ms | 1040 KB | Output is correct |
3 | Correct | 2 ms | 1040 KB | Output is correct |
4 | Correct | 2 ms | 1040 KB | Output is correct |
5 | Correct | 2 ms | 1040 KB | Output is correct |
6 | Correct | 2 ms | 1040 KB | Output is correct |
7 | Correct | 2 ms | 1040 KB | Output is correct |
8 | Correct | 2 ms | 1040 KB | Output is correct |
9 | Correct | 2 ms | 1040 KB | Output is correct |
10 | Correct | 2 ms | 1040 KB | Output is correct |
11 | Correct | 2 ms | 1040 KB | Output is correct |
12 | Correct | 2 ms | 1040 KB | Output is correct |
13 | Correct | 2 ms | 1088 KB | Output is correct |
14 | Correct | 2 ms | 1088 KB | Output is correct |
15 | Correct | 2 ms | 1088 KB | Output is correct |
16 | Correct | 2 ms | 1088 KB | Output is correct |
17 | Correct | 2 ms | 1088 KB | Output is correct |
18 | Correct | 2 ms | 1088 KB | Output is correct |
19 | Correct | 2 ms | 1088 KB | Output is correct |
20 | Correct | 2 ms | 1088 KB | Output is correct |
21 | Correct | 2 ms | 1088 KB | Output is correct |
22 | Correct | 2 ms | 1128 KB | Output is correct |
23 | Correct | 2 ms | 1128 KB | Output is correct |
24 | Correct | 2 ms | 1128 KB | Output is correct |
25 | Correct | 2 ms | 1128 KB | Output is correct |
26 | Correct | 2 ms | 1128 KB | Output is correct |
27 | Correct | 2 ms | 1128 KB | Output is correct |
28 | Correct | 2 ms | 1128 KB | Output is correct |
29 | Correct | 2 ms | 1128 KB | Output is correct |
30 | Correct | 2 ms | 1128 KB | Output is correct |
31 | Correct | 2 ms | 1128 KB | Output is correct |
32 | Correct | 2 ms | 1128 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1128 KB | Output is correct |
2 | Correct | 2 ms | 1128 KB | Output is correct |
3 | Correct | 2 ms | 1128 KB | Output is correct |
4 | Correct | 2 ms | 1128 KB | Output is correct |
5 | Correct | 2 ms | 1128 KB | Output is correct |
6 | Correct | 2 ms | 1128 KB | Output is correct |
7 | Correct | 2 ms | 1128 KB | Output is correct |
8 | Correct | 2 ms | 1128 KB | Output is correct |
9 | Correct | 2 ms | 1128 KB | Output is correct |
10 | Correct | 2 ms | 1128 KB | Output is correct |
11 | Correct | 2 ms | 1128 KB | Output is correct |
12 | Correct | 2 ms | 1140 KB | Output is correct |
13 | Correct | 2 ms | 1140 KB | Output is correct |
14 | Correct | 2 ms | 1248 KB | Output is correct |
15 | Correct | 2 ms | 1252 KB | Output is correct |
16 | Correct | 2 ms | 1252 KB | Output is correct |
17 | Correct | 2 ms | 1252 KB | Output is correct |
18 | Correct | 2 ms | 1268 KB | Output is correct |
19 | Correct | 2 ms | 1272 KB | Output is correct |
20 | Correct | 2 ms | 1276 KB | Output is correct |
21 | Correct | 2 ms | 1280 KB | Output is correct |
22 | Correct | 2 ms | 1316 KB | Output is correct |
23 | Correct | 2 ms | 1320 KB | Output is correct |
24 | Correct | 2 ms | 1324 KB | Output is correct |
25 | Correct | 2 ms | 1328 KB | Output is correct |
26 | Correct | 2 ms | 1332 KB | Output is correct |
27 | Correct | 2 ms | 1332 KB | Output is correct |
28 | Correct | 2 ms | 1332 KB | Output is correct |
29 | Correct | 2 ms | 1332 KB | Output is correct |
30 | Correct | 2 ms | 1332 KB | Output is correct |
31 | Correct | 2 ms | 1332 KB | Output is correct |
32 | Correct | 2 ms | 1332 KB | Output is correct |
33 | Correct | 2 ms | 1332 KB | Output is correct |
34 | Correct | 2 ms | 1332 KB | Output is correct |
35 | Correct | 2 ms | 1332 KB | Output is correct |
36 | Correct | 2 ms | 1332 KB | Output is correct |
37 | Correct | 2 ms | 1332 KB | Output is correct |
38 | Correct | 2 ms | 1356 KB | Output is correct |
39 | Correct | 2 ms | 1356 KB | Output is correct |
40 | Correct | 2 ms | 1356 KB | Output is correct |
41 | Correct | 2 ms | 1356 KB | Output is correct |
42 | Correct | 2 ms | 1412 KB | Output is correct |
43 | Correct | 2 ms | 1412 KB | Output is correct |
44 | Correct | 2 ms | 1412 KB | Output is correct |
45 | Correct | 2 ms | 1448 KB | Output is correct |
46 | Correct | 2 ms | 1448 KB | Output is correct |
47 | Correct | 2 ms | 1448 KB | Output is correct |
48 | Correct | 2 ms | 1448 KB | Output is correct |
49 | Correct | 2 ms | 1448 KB | Output is correct |
50 | Correct | 2 ms | 1484 KB | Output is correct |
51 | Correct | 2 ms | 1484 KB | Output is correct |
52 | Correct | 2 ms | 1484 KB | Output is correct |
53 | Correct | 2 ms | 1484 KB | Output is correct |
54 | Correct | 2 ms | 1484 KB | Output is correct |
55 | Correct | 2 ms | 1484 KB | Output is correct |
56 | Correct | 2 ms | 1484 KB | Output is correct |
57 | Correct | 2 ms | 1484 KB | Output is correct |
58 | Correct | 2 ms | 1484 KB | Output is correct |
59 | Correct | 2 ms | 1484 KB | Output is correct |
60 | Correct | 2 ms | 1484 KB | Output is correct |
61 | Correct | 2 ms | 1484 KB | Output is correct |
62 | Correct | 2 ms | 1484 KB | Output is correct |
63 | Correct | 2 ms | 1484 KB | Output is correct |
64 | Correct | 2 ms | 1684 KB | Output is correct |
65 | Correct | 2 ms | 1684 KB | Output is correct |
66 | Correct | 2 ms | 1684 KB | Output is correct |
67 | Correct | 2 ms | 1696 KB | Output is correct |
68 | Correct | 3 ms | 1700 KB | Output is correct |
69 | Correct | 3 ms | 1704 KB | Output is correct |
70 | Correct | 3 ms | 1708 KB | Output is correct |
71 | Correct | 2 ms | 1712 KB | Output is correct |
72 | Correct | 3 ms | 1716 KB | Output is correct |
73 | Correct | 4 ms | 1720 KB | Output is correct |
74 | Correct | 3 ms | 1724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1724 KB | Output is correct |
2 | Correct | 2 ms | 1724 KB | Output is correct |
3 | Correct | 2 ms | 1724 KB | Output is correct |
4 | Correct | 2 ms | 1724 KB | Output is correct |
5 | Correct | 2 ms | 1724 KB | Output is correct |
6 | Correct | 2 ms | 1724 KB | Output is correct |
7 | Correct | 2 ms | 1724 KB | Output is correct |
8 | Correct | 2 ms | 1724 KB | Output is correct |
9 | Correct | 2 ms | 1724 KB | Output is correct |
10 | Correct | 2 ms | 1724 KB | Output is correct |
11 | Correct | 2 ms | 1724 KB | Output is correct |
12 | Correct | 2 ms | 1724 KB | Output is correct |
13 | Correct | 2 ms | 1724 KB | Output is correct |
14 | Correct | 2 ms | 1724 KB | Output is correct |
15 | Correct | 2 ms | 1724 KB | Output is correct |
16 | Correct | 2 ms | 1724 KB | Output is correct |
17 | Correct | 2 ms | 1724 KB | Output is correct |
18 | Correct | 2 ms | 1724 KB | Output is correct |
19 | Correct | 2 ms | 1724 KB | Output is correct |
20 | Correct | 2 ms | 1724 KB | Output is correct |
21 | Correct | 2 ms | 1724 KB | Output is correct |
22 | Correct | 2 ms | 1724 KB | Output is correct |
23 | Correct | 2 ms | 1724 KB | Output is correct |
24 | Correct | 2 ms | 1724 KB | Output is correct |
25 | Correct | 2 ms | 1724 KB | Output is correct |
26 | Correct | 2 ms | 1724 KB | Output is correct |
27 | Correct | 2 ms | 1724 KB | Output is correct |
28 | Correct | 2 ms | 1724 KB | Output is correct |
29 | Correct | 2 ms | 1724 KB | Output is correct |
30 | Correct | 2 ms | 1724 KB | Output is correct |
31 | Correct | 3 ms | 1724 KB | Output is correct |
32 | Correct | 2 ms | 1724 KB | Output is correct |
33 | Correct | 3 ms | 1724 KB | Output is correct |
34 | Correct | 2 ms | 1724 KB | Output is correct |
35 | Correct | 2 ms | 1724 KB | Output is correct |
36 | Correct | 3 ms | 1724 KB | Output is correct |
37 | Correct | 2 ms | 1724 KB | Output is correct |
38 | Correct | 2 ms | 1724 KB | Output is correct |
39 | Correct | 2 ms | 1724 KB | Output is correct |
40 | Correct | 2 ms | 1724 KB | Output is correct |
41 | Correct | 2 ms | 1776 KB | Output is correct |
42 | Correct | 2 ms | 1776 KB | Output is correct |
43 | Correct | 2 ms | 1776 KB | Output is correct |
44 | Correct | 2 ms | 1776 KB | Output is correct |
45 | Correct | 2 ms | 1776 KB | Output is correct |
46 | Correct | 2 ms | 1776 KB | Output is correct |
47 | Correct | 2 ms | 1776 KB | Output is correct |
48 | Correct | 2 ms | 1776 KB | Output is correct |
49 | Correct | 2 ms | 1776 KB | Output is correct |
50 | Correct | 2 ms | 1776 KB | Output is correct |
51 | Correct | 2 ms | 1844 KB | Output is correct |
52 | Correct | 4 ms | 1880 KB | Output is correct |
53 | Correct | 3 ms | 1888 KB | Output is correct |
54 | Correct | 12 ms | 1912 KB | Output is correct |
55 | Correct | 5 ms | 1912 KB | Output is correct |
56 | Correct | 9 ms | 1916 KB | Output is correct |
57 | Correct | 9 ms | 2040 KB | Output is correct |
58 | Correct | 13 ms | 2040 KB | Output is correct |
59 | Correct | 9 ms | 2056 KB | Output is correct |
60 | Correct | 40 ms | 2056 KB | Output is correct |
61 | Correct | 2 ms | 2056 KB | Output is correct |
62 | Correct | 4 ms | 2080 KB | Output is correct |
63 | Correct | 14 ms | 2088 KB | Output is correct |
64 | Correct | 5 ms | 2100 KB | Output is correct |
65 | Correct | 6 ms | 2112 KB | Output is correct |
66 | Correct | 10 ms | 2160 KB | Output is correct |
67 | Correct | 38 ms | 2164 KB | Output is correct |
68 | Correct | 20 ms | 2184 KB | Output is correct |
69 | Correct | 11 ms | 2208 KB | Output is correct |