Submission #652942

#TimeUsernameProblemLanguageResultExecution timeMemory
652942mychecksedadPacking Biscuits (IOI20_biscuits)C++17
9 / 100
49 ms340 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back int n; ll count_tastiness(ll x, vector<ll> a){ n = 61; for(int i = 0; i < n-a.size(); ++i) a.pb(0); ll ans = 0; int sum = 0; for(int i = 0; i < min(n, 62); ++i) sum += (1ll<<i) * a[i]; if(sum/x <= 100000){ for(ll y = 0; y <= sum / x; ++y){ ll c = 0; bool ok = 1; for(ll j = 0; j < 63; ++j){ if((1ll<<j)&y){ c += a[j]; if(c<x){ ok = 0; break; } c-=x; }else{ c += a[j]; } c >>= 1; } if(ok) ans++; } return ans; }else{ vector<ll> b = a; int mx = -1, mx1 = -1; for(int i = 0; i < n - 1; ++i){ if(b[i] > 1) b[i + 1] += (b[i]-1)/2; if(b[i + 1] > 0) mx = i + 1; } ll ans = 1; for(int i = 0; i < n - 1; ++i) if(b[i]>0) ans *= 2; for(int i = 0; i < n - 1; ++i){ a[i + 1] += a[i]/2; if(a[i + 1] > 0) mx1 = i + 1; } if(mx!=mx1) ++ans; return ans; } return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < n-a.size(); ++i) a.pb(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...