Submission #824875

#TimeUsernameProblemLanguageResultExecution timeMemory
824875fatemetmhrPacking Biscuits (IOI20_biscuits)C++17
9 / 100
1083 ms49080 KiB
// Be name khoda // #include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << "(" << #x << "):" << x << endl; #define all(x) x.begin(), x.end() #define fi first #define se second #define pb push_back #define mp make_pair typedef long long ll; const int maxn5 = 1e6 + 10; pair <ll, ll> toadd[maxn5]; priority_queue <pair<ll, ll>> av; long long count_tastiness(long long x, std::vector<long long> a) { int k = 60; while(a.size() < k) a.pb(0); ll ans = 1; int ind = 0; while(ind < k){ if(a[ind] >= x + 2){ a[ind + 1] += (a[ind] - x) / 2; a[ind] -= ((a[ind] - x) / 2) * 2; } //if(a[ind]) cout << ind << ' ' << a[ind] << endl; ind++; } k = a.size(); while(av.size()) av.pop(); av.push({0, 1}); ll add = 0; for(int i = 0; i < k; i++){ ll tagh = (1ll << i); int pt = 0; while(av.size() && (av.top().fi + add) / tagh + a[i] >= x){ toadd[pt] = av.top(); av.pop(); toadd[pt + 1] = toadd[pt]; pt++; ans += toadd[pt].se; toadd[pt].fi -= tagh * x; pt++; } while(pt > 0){ av.push(toadd[pt - 1]); pt--; } add += a[i] * tagh; } return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:25:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |  while(a.size() < 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...