이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
using namespace std;
#include <bits/stdc++.h>
#include "biscuits.h"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
ll count_tastiness(ll x, vector<ll> a) {
int k = a.size() + 100;
rep(i,0,k) a.pb(0);
rep(i,0,k-1) {
if (a[i] <= x) continue;
a[i + 1] += (a[i] - x) / 2;
a[i] = x + ((a[i] - x) & 1);
}
vector<map<int,ll>> dp(k);
dp[0][a[0]] = 1;
if (a[0] >= x) dp[0][a[0] - x] = 1;
rep(i,0,k-1) for (auto [j, val] : dp[i]) {
if (dp[i+1].find(a[i+1] + j/2) == dp[i+1].end()) dp[i+1][a[i+1] + j/2] = 0;
dp[i+1][a[i+1] + j/2] += val;
if (a[i+1] + j/2 >= x) {
if (dp[i+1].find(a[i+1] + j/2 - x) == dp[i+1].end()) dp[i+1][a[i+1] + j/2 - x] = 0;
dp[i+1][a[i+1] + j/2 - x] += dp[i][j];
}
}
ll ans = 0;
rep(j,0,2*x+6) ans += dp[k-1][j];
return ans;
}
# | 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... |