# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83265 | 2018-11-06T12:57:55 Z | farukkastamonuda | Bali Sculptures (APIO15_sculpture) | C++14 | 229 ms | 16788 KB |
#include <bits/stdc++.h> #define li 2005 #define inf 1000000009 #define md 1000000007 #define lo long long #define fi first #define se second #define mp make_pair #define pb push_back #define LOG 40 using namespace std; int n,a,b,mn[li],dp[li][li],A[li]; vector<int> v[li]; bool check(lo int val){ for(int i=1;i<=n;i++){ v[i-1].clear(); mn[i]=inf; lo int sum=0; for(int j=i-1;j>=0;j--){ sum+=A[j+1]; if((sum|val)==val){ mn[i]=min(mn[i],mn[j]+1); v[j].pb(i); } } } if(a==1){ return mn[n]<=b; } memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int l=1;l<=n;l++){ for(int i=0;i<=n;i++){ if(dp[l-1][i]){ for(int j=0;j<(int)v[i].size();j++){ dp[l][v[i][j]]=1; } } } } for(int i=a;i<=b;i++){ if(dp[n][i]==1) return true; } return false; } int main(){ scanf("%d %d %d",&n,&a,&b); for(int i=1;i<=n;i++) scanf("%d",&A[i]); lo ans=((1LL<<(LOG+1))-1); for(int i=LOG;i>=0;i--){ ans-=(1LL<<i); if(!check(ans)) ans+=(1LL<<i); } printf("%lld\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 584 KB | Output is correct |
4 | Correct | 2 ms | 584 KB | Output is correct |
5 | Correct | 2 ms | 688 KB | Output is correct |
6 | Correct | 2 ms | 688 KB | Output is correct |
7 | Correct | 2 ms | 688 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 2 ms | 688 KB | Output is correct |
10 | Correct | 2 ms | 688 KB | Output is correct |
11 | Correct | 2 ms | 688 KB | Output is correct |
12 | Correct | 2 ms | 688 KB | Output is correct |
13 | Correct | 2 ms | 688 KB | Output is correct |
14 | Incorrect | 49 ms | 16416 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16416 KB | Output is correct |
2 | Correct | 3 ms | 16416 KB | Output is correct |
3 | Correct | 2 ms | 16416 KB | Output is correct |
4 | Correct | 2 ms | 16416 KB | Output is correct |
5 | Correct | 2 ms | 16416 KB | Output is correct |
6 | Correct | 3 ms | 16416 KB | Output is correct |
7 | Correct | 3 ms | 16416 KB | Output is correct |
8 | Correct | 2 ms | 16416 KB | Output is correct |
9 | Correct | 2 ms | 16416 KB | Output is correct |
10 | Correct | 2 ms | 16416 KB | Output is correct |
11 | Correct | 2 ms | 16416 KB | Output is correct |
12 | Correct | 2 ms | 16416 KB | Output is correct |
13 | Correct | 3 ms | 16416 KB | Output is correct |
14 | Incorrect | 65 ms | 16488 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16488 KB | Output is correct |
2 | Correct | 2 ms | 16488 KB | Output is correct |
3 | Correct | 2 ms | 16488 KB | Output is correct |
4 | Correct | 2 ms | 16488 KB | Output is correct |
5 | Correct | 2 ms | 16488 KB | Output is correct |
6 | Correct | 2 ms | 16488 KB | Output is correct |
7 | Correct | 2 ms | 16488 KB | Output is correct |
8 | Correct | 2 ms | 16488 KB | Output is correct |
9 | Correct | 2 ms | 16488 KB | Output is correct |
10 | Correct | 2 ms | 16488 KB | Output is correct |
11 | Correct | 2 ms | 16488 KB | Output is correct |
12 | Correct | 3 ms | 16488 KB | Output is correct |
13 | Correct | 2 ms | 16488 KB | Output is correct |
14 | Correct | 1 ms | 16488 KB | Output is correct |
15 | Correct | 2 ms | 16488 KB | Output is correct |
16 | Correct | 2 ms | 16488 KB | Output is correct |
17 | Correct | 2 ms | 16488 KB | Output is correct |
18 | Correct | 3 ms | 16488 KB | Output is correct |
19 | Correct | 2 ms | 16488 KB | Output is correct |
20 | Correct | 2 ms | 16488 KB | Output is correct |
21 | Correct | 3 ms | 16488 KB | Output is correct |
22 | Correct | 2 ms | 16488 KB | Output is correct |
23 | Correct | 3 ms | 16488 KB | Output is correct |
24 | Correct | 2 ms | 16488 KB | Output is correct |
25 | Correct | 2 ms | 16488 KB | Output is correct |
26 | Correct | 2 ms | 16488 KB | Output is correct |
27 | Correct | 3 ms | 16488 KB | Output is correct |
28 | Correct | 3 ms | 16488 KB | Output is correct |
29 | Correct | 3 ms | 16488 KB | Output is correct |
30 | Correct | 3 ms | 16488 KB | Output is correct |
31 | Correct | 3 ms | 16488 KB | Output is correct |
32 | Correct | 3 ms | 16488 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16488 KB | Output is correct |
2 | Correct | 2 ms | 16488 KB | Output is correct |
3 | Correct | 2 ms | 16488 KB | Output is correct |
4 | Correct | 2 ms | 16488 KB | Output is correct |
5 | Correct | 2 ms | 16488 KB | Output is correct |
6 | Correct | 2 ms | 16488 KB | Output is correct |
7 | Correct | 2 ms | 16488 KB | Output is correct |
8 | Correct | 2 ms | 16488 KB | Output is correct |
9 | Correct | 2 ms | 16488 KB | Output is correct |
10 | Correct | 2 ms | 16488 KB | Output is correct |
11 | Correct | 2 ms | 16488 KB | Output is correct |
12 | Correct | 2 ms | 16488 KB | Output is correct |
13 | Correct | 3 ms | 16488 KB | Output is correct |
14 | Incorrect | 58 ms | 16788 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16788 KB | Output is correct |
2 | Correct | 2 ms | 16788 KB | Output is correct |
3 | Correct | 2 ms | 16788 KB | Output is correct |
4 | Correct | 2 ms | 16788 KB | Output is correct |
5 | Correct | 2 ms | 16788 KB | Output is correct |
6 | Correct | 3 ms | 16788 KB | Output is correct |
7 | Correct | 2 ms | 16788 KB | Output is correct |
8 | Correct | 2 ms | 16788 KB | Output is correct |
9 | Correct | 2 ms | 16788 KB | Output is correct |
10 | Correct | 2 ms | 16788 KB | Output is correct |
11 | Correct | 2 ms | 16788 KB | Output is correct |
12 | Correct | 2 ms | 16788 KB | Output is correct |
13 | Correct | 2 ms | 16788 KB | Output is correct |
14 | Correct | 2 ms | 16788 KB | Output is correct |
15 | Correct | 2 ms | 16788 KB | Output is correct |
16 | Correct | 2 ms | 16788 KB | Output is correct |
17 | Correct | 2 ms | 16788 KB | Output is correct |
18 | Correct | 3 ms | 16788 KB | Output is correct |
19 | Correct | 2 ms | 16788 KB | Output is correct |
20 | Correct | 2 ms | 16788 KB | Output is correct |
21 | Correct | 2 ms | 16788 KB | Output is correct |
22 | Correct | 2 ms | 16788 KB | Output is correct |
23 | Correct | 2 ms | 16788 KB | Output is correct |
24 | Correct | 2 ms | 16788 KB | Output is correct |
25 | Correct | 2 ms | 16788 KB | Output is correct |
26 | Correct | 2 ms | 16788 KB | Output is correct |
27 | Correct | 2 ms | 16788 KB | Output is correct |
28 | Correct | 2 ms | 16788 KB | Output is correct |
29 | Correct | 2 ms | 16788 KB | Output is correct |
30 | Correct | 2 ms | 16788 KB | Output is correct |
31 | Correct | 2 ms | 16788 KB | Output is correct |
32 | Correct | 2 ms | 16788 KB | Output is correct |
33 | Correct | 2 ms | 16788 KB | Output is correct |
34 | Correct | 2 ms | 16788 KB | Output is correct |
35 | Correct | 2 ms | 16788 KB | Output is correct |
36 | Correct | 2 ms | 16788 KB | Output is correct |
37 | Correct | 2 ms | 16788 KB | Output is correct |
38 | Correct | 3 ms | 16788 KB | Output is correct |
39 | Correct | 4 ms | 16788 KB | Output is correct |
40 | Correct | 3 ms | 16788 KB | Output is correct |
41 | Correct | 3 ms | 16788 KB | Output is correct |
42 | Correct | 3 ms | 16788 KB | Output is correct |
43 | Correct | 2 ms | 16788 KB | Output is correct |
44 | Correct | 2 ms | 16788 KB | Output is correct |
45 | Correct | 2 ms | 16788 KB | Output is correct |
46 | Correct | 2 ms | 16788 KB | Output is correct |
47 | Correct | 2 ms | 16788 KB | Output is correct |
48 | Correct | 2 ms | 16788 KB | Output is correct |
49 | Correct | 3 ms | 16788 KB | Output is correct |
50 | Correct | 2 ms | 16788 KB | Output is correct |
51 | Correct | 2 ms | 16788 KB | Output is correct |
52 | Correct | 16 ms | 16788 KB | Output is correct |
53 | Correct | 25 ms | 16788 KB | Output is correct |
54 | Correct | 49 ms | 16788 KB | Output is correct |
55 | Correct | 45 ms | 16788 KB | Output is correct |
56 | Correct | 198 ms | 16788 KB | Output is correct |
57 | Correct | 187 ms | 16788 KB | Output is correct |
58 | Correct | 138 ms | 16788 KB | Output is correct |
59 | Correct | 152 ms | 16788 KB | Output is correct |
60 | Correct | 229 ms | 16788 KB | Output is correct |
61 | Correct | 3 ms | 16788 KB | Output is correct |
62 | Correct | 28 ms | 16788 KB | Output is correct |
63 | Correct | 58 ms | 16788 KB | Output is correct |
64 | Correct | 41 ms | 16788 KB | Output is correct |
65 | Correct | 96 ms | 16788 KB | Output is correct |
66 | Correct | 135 ms | 16788 KB | Output is correct |
67 | Correct | 184 ms | 16788 KB | Output is correct |
68 | Correct | 171 ms | 16788 KB | Output is correct |
69 | Correct | 160 ms | 16788 KB | Output is correct |