# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824880 | fatemetmhr | Packing Biscuits (IOI20_biscuits) | C++17 | 20 ms | 852 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Be name khoda //
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << "(" << #x << "):" << x << endl;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
const int maxn5 = 1e4 + 10;
ll dp[2][maxn5];
long long count_tastiness(long long x, std::vector<long long> a) {
int k = 60;
while(a.size() < k)
a.pb(0);
ll ans = 1;
int ind = 0;
while(ind < k){
if(a[ind] >= x + 2){
a[ind + 1] += (a[ind] - x) / 2;
a[ind] -= ((a[ind] - x) / 2) * 2;
}
//if(a[ind]) cout << ind << ' ' << a[ind] << endl;
ind++;
}
k = a.size();
memset(dp, 0, sizeof dp);
dp[1][0] = 1;
for(int i = 0; i < k; i++){
fill(dp[i&1], dp[i&1] + maxn5, 0);
for(int j = 0; j < maxn5; j++){
dp[i&1][(j + a[i]) / 2] += dp[(i&1)^1][j];
if(j + a[i] >= x){
ans += dp[(i&1)^1][j];
dp[i&1][(j + a[i] - x) / 2] += dp[(i&1)^1][j];
}
}
}
return ans;
}
Compilation message (stderr)
# | 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... |