Submission #932091

# Submission time Handle Problem Language Result Execution time Memory
932091 2024-02-23T01:09:55 Z beaboss Packing Biscuits (IOI20_biscuits) C++14
Compilation error
0 ms 0 KB
// Source: https://oj.uz/problem/view/IOI20_biscuits
// 

#include "bits/stdc++.h"

using namespace std;

#define s second
#define f first
#define pb push_back

typedef long long ll;

typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

typedef vector<ll> vi;

#define FOR(i, a, b) for (ll i = (a); i<b; i++)

bool ckmin(ll& a, ll b){ return b < a ? a = b, true : false; }

bool ckmax(ll& a, ll b){ return b > a ? a = b, true : false; }



ll count_tastiness(ll x, vector<ll> a) {

	vi dp(61);
	dp[0]=1;

	FOR(i, 1, 61) {
		ll mx = 0;
		ll alr = 0;
		ll tot = 0;

		for (ll j = i-1; j >= 0; j--) {
			tot += (1 << j) * a[j]; // biscuits we have
			ll groups = (tot >> j) / x ; // stuff we can make here, wrt j
			mx = 2ll * mx + 1ll; // add extra 1 bit
			// cout << mx << endl;
			groups = min(groups, mx);

			groups++;

			// cout << i << ' ' << groups << ' ' << alr << endl;
			// assert(alr <= groups);

			dp[i] += dp[j] * max(groups - alr, 0ll);

			alr = max(groups, alr) * 2ll;
		}
		// break;
	}

	return dp[60];

}

int main() {
	cout << count_tastiness(3, {5, 2, 1}) << endl;
}












Compilation message

/usr/bin/ld: /tmp/ccXtMj33.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccMFzHv4.o:biscuits.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status