Submission #828204

#TimeUsernameProblemLanguageResultExecution timeMemory
828204tomrukPacking Biscuits (IOI20_biscuits)C++17
35 / 100
29 ms1192 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long count_tastiness(long long x, vector<long long> a){ long long now = 0; for(int i = 0;i<a.size();i++){ a[i] += now; now = 0; if(a[i] > x){ now = (a[i] - x)/2; a[i] -= now * 2; } if(now && i == a.size() - 1) a.push_back(0); } int k = a.size(); // for(auto u:a){ // cout << u << ' '; // } // cout << endl; vector<long long> dp(k+1,0); dp[0] = 1; for(int i = 0;i<k;i++){ dp[i+1] = dp[i]; function<void(int,long long)> go = [&](int p,long long y) -> void{ // cout << p << ' ' << y << endl; long long coef = 1; long long last = 0; int tmp = p; while(p > 0 && y/coef < x){ coef *= 2; y *= 2; p--; if((y + a[p])/coef >= x){ last = x*coef - y; y = x * coef; } else{ last = a[p]; y += a[p]; } // cout << y << ' ' << coef << "ada" << endl; } if(y/coef < x) return; // cout << tmp << ' ' << p << endl; dp[i + 1] += dp[p]; if(tmp != p) go(p,a[p] - last); }; go(i,a[i]); // cout << i << ' ' << dp[i+1] << endl; } return dp[k]; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:6:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |  for(int i = 0;i<a.size();i++){
      |                ~^~~~~~~~~
biscuits.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   if(now && i == a.size() - 1)
      |             ~~^~~~~~~~~~~~~~~
#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...