Submission #315673

#TimeUsernameProblemLanguageResultExecution timeMemory
315673SortingPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1100 ms104396 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)){ int l = prev[0][0], r = prev.back()[0]; l += a[i], r += a[i]; if(l < x) 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){ int 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:29: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]
   29 |         for(int j = 0; j < prev.size(); ++j){
      |                        ~~^~~~~~~~~~~~~
biscuits.cpp:37: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]
   37 |     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...