이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
#include "biscuits.h"
const int K = 60;
long long count_tastiness(long long x, std::vector<long long> a) {
vector<ll>dp(K+1,0);
dp[0] = 1;
while(a.size() < K+5) a.pb(0);
vector<ll>gg(K+1,0),g(K+1,0);
for(int i = 0; i <= K; i++){
//if(a[i] > x) gg[i] = x*(1LL<<i), a[i] -= x, g[i] = x; else gg[i] = a[i]*(1LL<<i), g[i] = a[i], a[i] = 0;
//if(i) gg[i] += gg[i-1];
//a[i+1] += a[i]/2;
gg[i] = a[i] * (1LL<<i);
if(i) gg[i] += gg[i-1];
}
for(ll i = 1; i <= K; i++){
ll y = gg[i-1];
//cout << y << endl;
for(int k = i-1; k >= 0; k--){
y = min(y,gg[k]);
if(y < (1LL<<k)*x) continue;
dp[i] += dp[k];
y -= (1LL<<k)*x;
//cout << y << " " << k << endl;
}
dp[i]++;
/*
while(y >= 0 && k >= 0){
dp[i] += dp[k];
y -= x*(1LL<<k);
cout << y << " ";
cout << (1LL<<k) << " " << x*(1LL<<k) << " ";
cout << endl;
if(y < x && y >= 0){
dp[i]++;
break;
}
while((1LL<<k)*x > y) k--;
}*/
//cout << dp[i] << endl;
//if(i < a.size())sum += a[i]*p;
}
//cout << endl;
return dp[K];
}
# | 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... |