Submission #315676

#TimeUsernameProblemLanguageResultExecution timeMemory
315676SortingPacking Biscuits (IOI20_biscuits)C++17
42 / 100
1049 ms101172 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x, k; vector<ll> a; ll count_tastiness(ll _x, vector<ll> _a){ x = _x, a = _a; k = a.size(); vector<array<ll, 2>> curr, prev; prev.push_back({0, 1}); for(int i = 0; i < k; ++i, swap(curr, prev)){ ll l = prev[0][0], r = prev.back()[0]; l += a[i], r += a[i]; if(l < x){ if(r >= x) l = 0; else l = l / 2; } else l = (l - x) / 2; r = r / 2; curr.resize(r - l + 1); for(int j = 0; j < r - l + 1; ++j) curr[j] = {j + l, 0}; for(int j = 0; j < prev.size(); ++j){ ll t = prev[j][0] + a[i]; curr[t / 2 - l][1] += prev[j][1]; if(t >= x) curr[(t - x) / 2 - l][1] += prev[j][1]; } } ll ans = 0; for(int i = 0; i < prev.size(); ++i) ans += (prev[i][0] / x + 1) * prev[i][1]; return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int j = 0; j < prev.size(); ++j){
      |                        ~~^~~~~~~~~~~~~
biscuits.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = 0; i < prev.size(); ++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...