Submission #333321

#TimeUsernameProblemLanguageResultExecution timeMemory
333321nickmet2004Packing Biscuits (IOI20_biscuits)C++14
100 / 100
93 ms1004 KiB
#include<bits/stdc++.h>
#include "biscuits.h"
#define ll long long
using namespace std;
ll Xk;
ll dp[61] , Pr[61];
ll Q(ll w){
    if(w < 0ll)return 0ll;
    if(!w) return 1ll;
    int j;
    for(j = 60; ~j; --j) if((1ll << j) <= w)break;
    return dp[j] + Q(min(w , Pr[j] / Xk) - (1ll << j));
}
ll count_tastiness(ll X , vector<ll> a){
    int n = a.size(); Xk = X;
    a.resize(60);
    for(int i = 0; i < 60; ++i){
        Pr[i] = (1ll << i) * a[i];
        if(i)Pr[i] += Pr[i - 1];
    }
    //for(int i= 0; i < n; ++i)cout << Pr[i] <<  " "; cout << endl;
    dp[0] = 1ll;
    /// 2^k___2^(k+1) - 1
    /// dp[k + 1] = dp[k] + a;
    for(int k = 1; k < 61; ++k) dp[k] = Q((1ll << k) - 1ll);
    return dp[60];
}
/*
int main (){
    cout << count_tastiness(3 , {5 , 2 , 1});
}
*/

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:15:9: warning: unused variable 'n' [-Wunused-variable]
   15 |     int n = a.size(); Xk = X;
      |         ^
#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...