Submission #732954

#TimeUsernameProblemLanguageResultExecution timeMemory
732954PoonYaPatPacking Biscuits (IOI20_biscuits)C++14
0 / 100
15 ms1192 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll qs[61],sum,bag; ll find(ll x) { if (x<0) return 0; if (x==0) return 1; if (x==1) return qs[0]; int k; for (int i=59; i>0; --i) { if ((1ll<<i)<=x) { k=i; break; } } return qs[k-1]+find(min(x-(1ll<<k),sum/bag-(1ll<<k))); } ll count_tastiness(ll X, vector<ll> a) { bag=X; sum=a[0]; if (a[0]>=bag) qs[0]=2; else qs[0]=1; for (int i=1; i<60; ++i) { if (i<a.size()) sum+=a[i]*(1ll<<i); qs[i]=find((1ll<<(i+1))-1); } return qs[59]; }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:30:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (i<a.size()) sum+=a[i]*(1ll<<i);
      |             ~^~~~~~~~~
biscuits.cpp: In function 'll find(ll)':
biscuits.cpp:20:52: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     return qs[k-1]+find(min(x-(1ll<<k),sum/bag-(1ll<<k)));
      |                                                ~~~~^~~~
#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...