Submission #303678

#TimeUsernameProblemLanguageResultExecution timeMemory
303678junseoPacking Biscuits (IOI20_biscuits)C++17
9 / 100
1084 ms525820 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define rmin(r, x) r = min(r, x)
#define rmax(r, x) r = max(r, x)
#define ends ' '
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxk = 65;

int k;
ll s[maxk];

long long count_tastiness(long long x, std::vector<long long> a) {
	k = a.size();
	a.resize(maxk);
	s[0] = a[0];
	for(int i = 1; i <= 60; ++i)	s[i] = s[i - 1] + (1LL << i) * a[i];
	
	vector<ll> ans;
	ans.eb(0);
	for(int i = 0; i <= 60; ++i) {
		vector<ll> t;
		for(auto y : ans) {
			y += (1LL << i);
			if(s[i] / x >= y)	t.eb(y);
			else	break;
		}
		ans.insert(ans.end(), all(t));
	}
	assert(ans.size() <= 2e5);
	return ans.size();
}
#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...