Submission #430072

#TimeUsernameProblemLanguageResultExecution timeMemory
430072alishahali1382Packing Biscuits (IOI20_biscuits)C++14
0 / 100
11 ms332 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())

const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int N=61;

ll n, m, k, x, y, u, v, t, a, b;
ll A[N];
map<ll, ll> dp;

ll Solve(ll n){
	// #y<=n
	if (n<0) return 0;
	if (!n) return 1;
	if (dp.count(n)) return dp[n];
	// debug(n)
	int k=0;
	while ((2ll<<k)<=n) k++;
	dp[n]=Solve((1ll<<k)-1);
	dp[n]+=Solve(min((1ll<<k)-1, A[k]-(1ll<<k)));
	return dp[n];
}

ll count_tastiness(ll x, vector<ll> _A){
	_A.resize(N, 0);
	for (int i=0; i<N; i++) A[i]=_A[i];
	for (int i=1; i<N; i++) A[i]=(A[i]<<i)+A[i-1];
	for (int i=0; i<N; i++) A[i]=(A[i])/x;
	dp.clear();
	ll ans=Solve((1ll<<N)-1);
	/*
	for (ll y=0; y<=A[N-1]; y++){
		int ok=1;
		for (int i=0; i<N && ok; i++) if ((y&((1ll<<(i+1))-1))>A[i]) ok=0;
		ans+=ok;
	}*/

	return ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...