This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "biscuits.h"
#include "bits/stdc++.h"
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define SZ(a) int(a.size())
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
const int inf = 1001001001;
const ll linf = 1001001001001001001;
template<class T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll count_tastiness(ll x, vl a) {
a.resize(60);
rep(i, 59) {
if (a[i] >= x) {
ll l = (a[i] - x) / 2;
a[i + 1] += l;
a[i] -= l * 2;
}
}
vl dp(60);
dp[0] = (a[0] >= x ? 2 : 1);
rep2(i, 1, 60) {
dp[i] = dp[i - 1];
if (a[i] >= x) {
dp[i] *= 2;
continue;
}
ll rq = (x - a[i]) * 2;
rrep(j, i) {
assert(2 <= rq and rq <= 2 * x);
if (a[j] < rq) {
if (rq - a[j] > x) break;
rq = (rq - a[j]) * 2;
} else {
dp[i] += (j ? dp[j - 1] : 1);
rq = (rq + x - a[j]) * 2;
}
}
}
// rep(i, 60) cerr << i << ' ' << dp[i] << endl;
return dp[59];
}
# | 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... |