Submission #238879

#TimeUsernameProblemLanguageResultExecution timeMemory
238879thtsshz_bgwrswhBali Sculptures (APIO15_sculpture)C++17
0 / 100
5 ms512 KiB
#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 (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&num[i]);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...