이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxk = 63;
ll n, dp[maxk], b[maxk];
long long count_tastiness(long long x, vector<long long> a)
{
a.resize(maxk);
n = a.size();
b[0] = a[0];
for (int i = 1; i < maxk; i ++)
{
b[i] = b[i - 1] / 2 + a[i];
}
dp[0] = 1;
if (a[0] != 0)
dp[0] ++;
for (ll i = 1; i < maxk; i ++)
{
dp[i] = 0;
if (b[i] < x)
{
///cout << "here " << i << " " << b[i] << " " << x << endl;
dp[i] = dp[i - 1];
continue;
}
dp[i] = dp[i - 1];
if (a[i] >= x)
{
dp[i] += dp[i - 1];
continue;
}
ll nec = (x - a[i]) * 2;
for (int j = i - 1; j >= 0; j --)
{
///cout << i << " : " << j << " : " << nec << " : " << a[j] << endl;
if (a[j] >= nec + x)
{
dp[i] = dp[i] + dp[j];
break;
}
if (a[j] >= nec)
{
if (j == 0)
dp[i] ++;
else
dp[i] = dp[i] + dp[j - 1];
nec = (x - (a[j] - nec)) * 2;
}
else
{
nec = (nec - a[j]) * 2;
}
}
}
//for (int j = 0; j < 5; j ++)
// cout << dp[j] << " ";
//cout << endl;
return dp[maxk - 1];
}
# | 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... |