Submission #303396

#TimeUsernameProblemLanguageResultExecution timeMemory
303396qiangbaoPacking Biscuits (IOI20_biscuits)C++14
0 / 100
8 ms384 KiB
#include <iostream> #include <vector> #include "biscuits.h" using namespace std; typedef long long ll; ll ways[64]; ll pow2[64]; void ini() { ll i; pow2[0]=1; for(i=1;i<=63;i++) pow2[i]=pow2[i-1]*2; for(i=0;i<=63;i++) ways[i]=0; ways[0]=1; } ll count_tastiness(ll x, vector<ll> a) { ll tot=0; ll i, j; a.resize(64); ini(); for(i=0;i<64;i++){ ll way=0; tot+=a[i]*pow2[i]; ll tot2=tot; for(j=i;j>=0;j--) if(tot2>=x*pow2[j]) tot2-=x*pow2[j], way+=ways[j]; ways[i+1]=way+1; } return ways[63]; } //int main() //{ // cout << count_tastiness(1, {2}) << endl; //}

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:40:18: warning: iteration 63 invokes undefined behavior [-Waggressive-loop-optimizations]
   40 |         ways[i+1]=way+1;
      |         ~~~~~~~~~^~~~~~
biscuits.cpp:33:14: note: within this loop
   33 |     for(i=0;i<64;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...