이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
ll count_tastiness(ll x, vll a) {
while(a.size()<60) a.pb(0);
vll b; b=a;
REP(i,1,60) b[i]+=b[i-1]/2;
vll dp; dp.assign(61,0);
dp[0] = 1;
RE(i,60) {
if(b[i]<x) {
dp[i+1] = dp[i];
continue;
}
ll add=0, needed=max(0ll, x-a[i])*2ll;
REV(j,1,i+1) {
if(b[j-1] >= needed+x) add += dp[j-1], needed = max(0ll, needed+x-a[j-1])*2ll;
else needed = max(0ll, needed-a[j-1])*2ll;
}
if(needed == 0) add++;
dp[i+1] = dp[i]+add;
}
return dp[60];
}
# | 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... |