Submission #309895

#TimeUsernameProblemLanguageResultExecution timeMemory
309895CaroLindaPacking Biscuits (IOI20_biscuits)C++14
0 / 100
2 ms384 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
 
#define all(x) x.begin(),x.end()
#define ll long long
 
using namespace std ;
 
 
long long count_tastiness(long long x, vector<long long> a ) 
{
 
 
	while( (int)(a.size()) < 60 ) { a.push_back(0LL) ; } ;
 
	vector<ll> pos(1,0LL) ;
 
	ll curSoma = 0LL ;
 
	for(int i = 0 ; i < 30 && (LLONG_MAX/x) < (1LL<<i); i++ )
	{
		curSoma += a[i] * (1LL<<i) ;
 		
		int idx = upper_bound(all(pos), curSoma - x*(1LL<<i) ) - pos.begin() - 1 ;

		for(int j = 0 ; j <= idx ; j++ )
			pos.push_back( pos[j] + x*(1LL<<i) ) ;
 
	}
 
	return (int)(pos.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...