제출 #1031309

#제출 시각아이디문제언어결과실행 시간메모리
1031309happy_nodePacking Biscuits (IOI20_biscuits)C++17
100 / 100
47 ms1372 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;

map<ll, ll> dp;

vector<ll> s;

ll x;

ll g(ll n) {
	if(n<=0) return 0;
	if(n==1) return 1;
	if(dp.count(n)) return dp[n];
	ll b=0, p=1;
	while(p<n) b++,p*=2;
	p/=2;
	b--;
	return dp[n]=g(p)+g(min(n,1+s[b]/x)-p);
}
 
long long count_tastiness(long long X, std::vector<long long> a) {
	x=X;
	while(a.size()<60) a.push_back(0);
 	
 	s.clear();
 	dp.clear();
 	ll sum=0;
 	for(int i=0;i<60;i++) {
 		sum+=(1LL<<i)*a[i];
 		s.push_back(sum);
 	}

 	return g(1LL<<60);
}
#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...