Submission #742247

#TimeUsernameProblemLanguageResultExecution timeMemory
742247arthur_nascimentoPacking Biscuits (IOI20_biscuits)C++14
77 / 100
1086 ms824 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define ll long long #define debug ll ans[200]; ll sum[200]; long long count_tastiness(long long x, std::vector<long long> a) { for(int i=0;i<62;i++) a.push_back(0); int k = a.size(); ll tot = 1; for(int i=0;i<k;i++){ debug("i %d\n",i); ll lo = -1, hi = tot-1; while(lo < hi){ ll mid = (lo+hi+1)/2; ll num = 0, aux = mid; for(int j=i-1;j>=0;j--) if(aux >= sum[j] - ans[j]){ num |= (1ll << j); aux -= (sum[j] - ans[j]); } ll val = 0; for(int j=0;j<i;j++){ val += a[j]; if(num & (1ll << j)) val -= x; val /= 2; } val += a[i]; debug("mid %lld -> %lld, num %lld\n",mid,val,num); if(val >= x) lo = mid; else hi = mid-1; } debug("add %d\n",lo+1); ans[i] = lo+1; tot += ans[i]; sum[i] = tot; } return tot; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:19:9: warning: left operand of comma operator has no effect [-Wunused-value]
   19 |   debug("i %d\n",i);
      |         ^~~~~~~~
biscuits.cpp:48:10: warning: left operand of comma operator has no effect [-Wunused-value]
   48 |    debug("mid %lld -> %lld, num %lld\n",mid,val,num);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
biscuits.cpp:48:45: warning: right operand of comma operator has no effect [-Wunused-value]
   48 |    debug("mid %lld -> %lld, num %lld\n",mid,val,num);
      |                                             ^~~
biscuits.cpp:48:49: warning: right operand of comma operator has no effect [-Wunused-value]
   48 |    debug("mid %lld -> %lld, num %lld\n",mid,val,num);
      |                                                 ^~~
biscuits.cpp:58:9: warning: left operand of comma operator has no effect [-Wunused-value]
   58 |   debug("add %d\n",lo+1);
      |         ^~~~~~~~~~
#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...