이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///
/// Standing here
/// I realize
/// You are just like me
/// Trying to make history
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define Kill(x) exit((cout << (x) << '\n', 0))
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
using namespace std;
#ifndef LOCAL
#include "biscuits.h"
#else
ll count_tastiness(ll, vector<ll>);
int main()
{
cout << count_tastiness(3, {5, 2, 1}) << '\n';
}
#endif
const int K = 63, X = 10010;
ll mm[K][X], a[K];
ll x;
ll solve(int i, ll rem)
{
if (i == K)
return rem/x + 1;
if (x <= 10000 && mm[i][rem] != -1)
return mm[i][rem];
ll ans = solve(i+1, (rem+a[i])/2);
if (rem + a[i] >= x)
ans += solve(i+1, (rem+a[i]-x)/2);
if (x <= 10000)
mm[i][rem] = ans;
return ans;
}
ll count_tastiness(ll _x, vector<ll> _a)
{
x = _x; _a.resize(K);
memset(mm, -1, sizeof(mm));
memset(a, 0, sizeof(a));
Loop (i,0,K-1) {
a[i] += _a[i];
if (a[i] > x) {
ll y = (a[i]-x)/2;
a[i+1] += y;
a[i] -= y*2;
}
}
return solve(0, 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... |