| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 828000 | minhcool | Packing Biscuits (IOI20_biscuits) | C++17 | 15 ms | 9864 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.
//#define local
#ifndef local
#include "biscuits.h"
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
return abs(temp) + l;
}
int dp[61][20005], expected[61];
long long count_tastiness(long long x, std::vector<long long> a) {
//int n, a[N];
int sum = 0;
for(int i = 0; i < a.size(); i++) sum += a[i] * (1LL << i);
if(sum <= 1e5){
int answer = 1;
for(int i = 1; i <= sum/x; i++){
int rem = 0;
for(int j = 0; j < a.size(); j++){
rem += a[j];
if((i & (1LL << j))) rem -= x;
if(rem < 0) break;
rem /= 2;
}
answer += (rem >= 0);
}
return answer;
}
else if(x <= 1e4){
for(int i = 0; i <= 20000; i++){
for(int j = 0; j <= 60; j++) dp[j][i] = 0;
}
expected[0] = a[0];
for(int i = 1; i < a.size(); i++) expected[i] = (expected[i - 1] / 2) + a[i];
dp[0][0] = 1;
if(a[0] >= x) dp[0][x] = 1;
for(int i = 0; (i + 1) < a.size(); i++){
for(int j = 0; j <= 20000; j++){
int nxt = ((expected[i] - j) / 2) + a[i + 1], actual = expected[i + 1] - nxt;
dp[i + 1][actual] += dp[i][j];
if(nxt >= x){
nxt -= x, actual += x;
dp[i + 1][actual] += dp[i][j];
}
}
}
int answer = 0;
for(int j = 0; j <= 20000; j++) answer += dp[a.size() - 1][j];
return answer;
}
return 0;
}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... | ||||
