Submission #303699

#TimeUsernameProblemLanguageResultExecution timeMemory
303699JooDdaePacking Biscuits (IOI20_biscuits)C++17
9 / 100
1136 ms633412 KiB
#include<bits/stdc++.h> #include "biscuits.h" using namespace std; using ll = long long; ll INF = 1e18; ll count_tastiness(ll x, vector<ll> a) { ll ans = 0, sum = 0; for(int i=0;i<a.size();i++) sum += (1ll << i) * a[i]; ll mx = sum / x; while((1ll << a.size()) < mx) a.push_back(0); queue<ll> qu, qc, ql; qu.push(0), qc.push(0), ql.push(0), ans++; while(!qu.empty()){ ll u = qu.front(), c = qc.front(), l = ql.front() / 2 + a[c]; qu.pop(), qc.pop(), ql.pop(); if(u + (1ll << c) > mx) continue; qu.push(u), qc.push(c + 1), ql.push(l); if(l >= x){ ans++; qu.push(u + (1ll << c)), qc.push(c + 1), ql.push(l - x); } } return ans; }

Compilation message (stderr)

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