# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
76814 | 2018-09-18T12:12:39 Z | vex | Bali Sculptures (APIO15_sculpture) | C++14 | 3 ms | 740 KB |
#include <bits/stdc++.h> #define maxn 2005 using namespace std; int n,a,b; long long s[maxn]; bool moze(int x) { int g=0; int pr=0; long long tr=1LL<<x; for(int i=1;i<=n;i++) { if(s[i]-s[pr]>=tr) { if(i==pr+1)return false; g++; pr=i-1; i--; } else if(i==n)g++; } if(g<=b)return true; return false; } int numbit() { int l=1; int r=50; int sol; while(l<=r) { int mid=(l+r)/2; if(moze(mid)) { sol=mid; r=mid-1; } else l=mid+1; } return sol; } bool t[maxn][maxn]; bool exist(long long br0,int numb) { long long br=1LL<<numb; for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)t[i][j]=false; t[0][0]=true; for(int i=1;i<=n;i++) for(int j=0;j<i;j++) { if(((s[i]-s[j])&br0)==0LL && (s[i]-s[j])<br) { for(int k=0;k<=n-1;k++)if(t[j][k])t[i][k+1]=true; } } for(int i=a;i<=b;i++)if(t[n][i])return true; return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>a>>b;s[0]=0LL; for(int i=1;i<=n;i++) { int x; cin>>x; s[i]=s[i-1]+x; } int br=numbit(); long long sol=1LL<<(br-1); long long obr=0; for(int i=br-2;i>=0;i--) { obr+=1LL<<i; if(!exist(obr,br)) { obr-=1LL<<i; sol+=1LL<<i; } } cout<<sol<<endl; return 0; } /* 6 1 3 8 1 2 1 5 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Incorrect | 2 ms | 440 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 488 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Incorrect | 3 ms | 532 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 540 KB | Output is correct |
2 | Correct | 2 ms | 676 KB | Output is correct |
3 | Incorrect | 2 ms | 676 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 676 KB | Output is correct |
2 | Correct | 2 ms | 676 KB | Output is correct |
3 | Incorrect | 2 ms | 676 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 676 KB | Output is correct |
2 | Correct | 2 ms | 740 KB | Output is correct |
3 | Incorrect | 2 ms | 740 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |