This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define pb emplace_back
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
ll vec[200005];
ll count_tastiness(ll K,vi v){
ll n=61;
while(v.size()<n)v.pb(0);
rep(i,n)v[i]=v[i]<<i;
rep(i,n-1)v[i+1]+=v[i];
rep(i,n)v[i]/=K;
/*
vec[0]=0;
ll cnt=1;
rep(i,n){
ll k=1ll<<i,l=lower_bound(vec,vec+cnt,v[i]-k+1)-vec;
rep(j,l)vec[cnt++]=vec[j]+k;
}
return cnt;
*/
// outv(v);
vi dp(n+1),rui(n+1);dp[0]=rui[0]=1;
rep(i,n){
ll k=1ll<<i,t=v[i]-k;
if(t>0){
t=min(t,k-1);
for(ll j=i-1;j>=0;j--)if(t>>j&1){
// cout<<i<<' '<<j<<endl;
dp[i+1]+=rui[j];
t=min(t-(1ll<<j),v[j]-(1ll<<j));
if(t<0)break;
}
}
if(t==0)dp[i+1]++;
rui[i+1]=rui[i]+dp[i+1];
}
// outv(dp);outv(rui);
return rui[n];
}
Compilation message (stderr)
biscuits.cpp: In function 'll count_tastiness(ll, vi)':
biscuits.cpp:21:19: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
21 | while(v.size()<n)v.pb(0);
| ~~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |