(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #311606

#TimeUsernameProblemLanguageResultExecution timeMemory
311606milisavPacking Biscuits (IOI20_biscuits)C++14
100 / 100
20 ms896 KiB
#include<bits/stdc++.h> #include "biscuits.h" using namespace std; long long count_tastiness(long long x, std::vector<long long> a) { long long t[70]; long long psum[70]; long long deg[70]; int k=60; while(a.size()<k) a.push_back(0); for(long long i=0;i<k;i++) { t[i]=0; psum[i]=0; deg[i]=(1ll<<i); } psum[0]=a[0]; for(int i=1;i<k;i++) psum[i]=psum[i-1]+a[i]*deg[i]; int mk=0; long long ts=psum[k-1]; for(int i=0;i<k;i++) { if(ts/x<deg[i]) { t[i]=((i==0) ? 1 : t[i-1]); continue; } if(i==0) { if(a[i]>=x) t[i]=2; else t[i]=1; } else { if(a[i]>=x) t[i]=2*t[i-1]; else { long long nec=(x-a[i])*deg[i]; long long tot=0; for(int j=i-1;j>=0;j--) { long long bd=min((psum[j]-nec)/x,deg[j+1]-1); if(bd>=deg[j]) { tot+=(j==0 ? 1 : t[j-1]); nec=max(nec+(x-a[j])*deg[j],0ll); } else nec=max(nec-deg[j]*a[j],0ll); } t[i]=t[i-1]+tot+(nec==0); } } } return t[k-1]; } /*int main() { int q; assert(scanf("%d", &q) == 1); vector<int> k(q); vector<long long> x(q); vector<vector<long long>> a(q); vector<long long> results(q); for (int t = 0; t < q; t++) { assert(scanf("%d%lld", &k[t], &x[t]) == 2); a[t] = vector<long long>(k[t]); for (int i = 0; i < k[t]; i++) { assert(scanf("%lld", &a[t][i]) == 1); } } fclose(stdin); for (int t = 0; t < q; t++) { results[t] = count_tastiness(x[t], a[t]); } for (int t = 0; t < q; t++) { printf("%lld\n", results[t]); } fclose(stdout); return 0; }*/

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:10:19: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     while(a.size()<k) a.push_back(0);
      |           ~~~~~~~~^~
biscuits.cpp:18:9: warning: unused variable 'mk' [-Wunused-variable]
   18 |     int mk=0;
      |         ^~
#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...