| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 826371 | Lobo | Packing Biscuits (IOI20_biscuits) | C++17 | 1 ms | 380 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.
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
long long count_tastiness(long long X, std::vector<long long> A) {
int x = X;
int k = 60;
vector<int> a(k+1,0), dp(k+1,0);
for(int i = 0; i < A.size(); i++) a[i] = A[i];
vector<int> pf(k+1,0);
pf[0] = a[0];
for(int i = 1; i <= k; i++) pf[i] = pf[i-1]+a[i]*(1LL<<i);
vector<int> pfdp(k+1,0);
for(int i = 0; i <= k; i++) {
if((1LL<<i) > (int) 1e18 / x || pf[i] < x*(1LL<<i)) {
dp[i] = 0;
pfdp[i] = dp[i] + (i == 0 ? 0 : pfdp[i-1]);
continue;
}
int sum = x*(1LL<<i);
for(int j = i; j >= 0; j--) {
if(sum - a[j]*(1LL<<j) <= 0) {
dp[i]+= 1 + (j == 0 ? 0 : pfdp[j-1]);
sum = x*(1LL<<j) - (a[i]*(1LL<<j)-sum);
}
else {
sum-= a[i]*(1LL<<j);
}
}
pfdp[i] = dp[i] + (i == 0 ? 0 : pfdp[i-1]);
}
return pfdp[k]+1;
}
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... | ||||
