# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238879 | 2020-06-13T10:50:50 Z | thtsshz_bgwrswh | Bali Sculptures (APIO15_sculpture) | C++17 | 5 ms | 512 KB |
#pragma GCC optimize("Ofast") #include<stdio.h> #include<math.h> #include<algorithm> using namespace std; long long num[2005],n,a,b; bool check(long long v){ long long i,cnt=0; for(i=0;i<n;){ long long index=i,ans=num[i]; cnt++; if(ans>v) return 0; while(index+1<n&&num[index+1]+ans<=v){ index++; ans+=num[index+1]; } i=index+1; } return (cnt<=b); } bool check2(long long v,long long pos){ long long i,cnt=0; for(i=0;i<n;){ long long index=i,ans=num[i]; cnt++; if(ans>v||((num[index+1]+ans)>>pos)&1) return 0; while(index+1<n&&num[index+1]+ans<=v&&!(((num[index+1]+ans)>>pos)&1)){ index++; ans+=num[index+1]; } i=index+1; } return (cnt<=b); } int main(){ long long i; scanf("%lld%lld%lld",&n,&a,&b); for(i=0;i<n;i++) scanf("%lld",&num[i]); for(i=0;i<45;i++) if(check((1<<(i+1))-1)) break; long long ans=(1<<(i+1))-1; for(;i>=0;i--){ if(check2(ans^(1<<i),i)) ans^=(1<<i); } printf("%lld\n",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Incorrect | 5 ms | 512 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 5 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |