Submission #829107

# Submission time Handle Problem Language Result Execution time Memory
829107 2023-08-18T04:34:39 Z definitelynotmee Packing Biscuits (IOI20_biscuits) C++17
Compilation error
0 ms 0 KB
#include "biscuits.h"
#include"grader.cpp"
#include<bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const ll INFL = numeric_limits<ll>::max();
using pll = pair<ll,ll>;


long long count_tastiness(long long x, std::vector<long long> a) {
	a.resize(60,0);

	int k = a.size();

	
	vector<pll> dp;

	auto resp_for_carry =[&](ll carry){
		return lower_bound(all(dp),pll({carry,0ll}))->ss;
	};

	auto getdp =[&](ll vi, ll carry){
		return resp_for_carry(2*(carry-vi)) + resp_for_carry(2*(carry+x-vi));
	};
	dp.push_back({0,1});
	dp.push_back({INFL,0});

	auto dc =[&](ll l, ll r, ll respl, ll respr, ll vi, vector<pll> & newdp, auto dc) -> void {
		if(l > r || respl == respr)
			return;
		ll m = (l+r)>>1;


		ll cur = getdp(vi,m);
		newdp.push_back({m,cur});

		dc(l,m-1,respl,cur,vi,newdp,dc);
		dc(m+1,r,cur,respr,vi,newdp,dc);
	};

	for(int i = 0; i < 60; i++){
		vector<pll> newdp;
		newdp.push_back({0,getdp(a[i],0)});
		newdp.push_back({INFL,0});

		dc(1,4e18, newdp[0].ss, 0, a[i], newdp, dc);

		sort(all(newdp));

		dp.swap(newdp);
	}
	return dp[0].ss;

}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:17:6: warning: unused variable 'k' [-Wunused-variable]
   17 |  int k = a.size();
      |      ^
/usr/bin/ld: /tmp/ccirpGD4.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cccQoJF4.o:biscuits.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status