# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1207136 | tkm_algorithms | Packing Biscuits (IOI20_biscuits) | C++20 | 0 ms | 0 KiB |
/**
* In the name of Allah
* We are nothing and you're everything
**/
#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
//#define int long long
const char nl = '\n';
const int max_sum = 1e5;
ll count_tastiness(ll x, vector<ll> a) {
int k = sz(a);
vector<ll> onki = a;
if (x > max_sum)return 1;
auto check = [&](int y) {
int rep = x;
while (rep--) {
int want = y;
for (int t = k-1; t >= 0; --t) {
int d = min(want/(1ll<<t), a[t]);
a[t] -= d; want -= (1ll<<t)*d;
}
if (want > 0)return 0;
}
return 1;
};
int res = 0;
for (int i = 0; i*x <= max_sum; ++i) {
res += check(i); a = onki;
}
return res;
}
//int32_t main() {
//ios::sync_with_stdio(0);
//cin.tie(0);
//cout << count_tastiness(2, {2, 1, 2});
//return 0;
//}
/**
* In the name of Allah
* We are nothing and you're everything
**/
#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
//#define int long long
const char nl = '\n';
const int max_sum = 1e5;
ll count_tastiness(ll x, vector<ll> a) {
int k = sz(a);
vector<ll> onki = a;
if (x > max_sum)return 1;
auto check = [&](int y) {
int rep = x;
while (rep--) {
int want = y;
for (int t = k-1; t >= 0; --t) {
int d = min(want/(1ll<<t), a[t]);
a[t] -= d; want -= (1ll<<t)*d;
}
if (want > 0)return 0;
}
return 1;
};
int res = 0;
for (int i = 0; i*x <= max_sum; ++i) {
res += check(i); a = onki;
}
return res;
}
//int32_t main() {
//ios::sync_with_stdio(0);
//cin.tie(0);
//cout << count_tastiness(2, {2, 1, 2});
//return 0;
//}