이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#include "biscuits.h"
long long count_tastiness(long long x, std::vector<long long> a) {
for (int i = 0;i < 60;i++) a.push_back(0);
int k = a.size();
for (int i = 0;i < k-1;i++) {
ll d = max(0LL, a[i] - x);
a[i] -= d;
a[i+1] += d/2;
}
vector<ll> cnt(2*x+2, 0);
int n = 2*x+2;
cnt[0] = 1;
for (int i = 0;i < k;i++) {
for (int j = n-1;j >= 0;j--) {
if (j >= a[i]) cnt[j] = cnt[j-a[i]];
else cnt[j] = 0;
}
for (int j = 0;j < n;j++) {
if (j >= x) cnt[j-x] += cnt[j];
}
for (int j = 0;j < n;j++) {
cnt[j] = (j*2 < n ? cnt[j*2] : 0) + (j*2+1 < n ? cnt[j*2+1] : 0);
}
//pary(cnt.begin(), cnt.end());
}
ll ans = 0;
for (int i = 0;i < n;i++) ans += cnt[i];
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... |