이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 65;
int n;
long long x;
long long a[maxn];
map<pair<int, long long>, long long> dp;
long long f(int pos, long long carry)
{
if (pos == n)
{
return carry / x + 1;
}
if (dp.find(make_pair(pos, carry)) != dp.end())
{
return dp[make_pair(pos, carry)];
}
carry += a[pos];
long long ans = f(pos + 1, carry / 2);
if (carry >= x)
{
ans += f(pos + 1, (carry - x) / 2);
}
return dp[make_pair(pos, carry)] = ans;
}
long long count_tastiness(long long X, vector<long long> arr)
{
dp.clear();
n = arr.size();
x = X;
for (int i = 0; i < n; ++i)
{
a[i] = arr[i];
}
return f(0, 0);
}
/*
1
3 3
5 2 1
1
3 2
2 1 2
2
3 3
5 2 1
3 2
2 1 2
*/
# | 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... |