Submission #862488

# Submission time Handle Problem Language Result Execution time Memory
862488 2023-10-18T10:32:23 Z sunwukong123 Packing Biscuits (IOI20_biscuits) C++14
0 / 100
1 ms 528 KB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = -1;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi; 
int ans;

long long count_tastiness(long long X, std::vector<long long> vec) {
	ans=1;//0
	int L=vec.size();
	while((int)vec.size()<2*L)vec.push_back(0);
	for(int i=0;i<2*L;i++){ // let's count the numbers st the biggest bit is 2^i
		int smallest=0;
		/*
		int debt=0;
		for(int j=i-1;j>=0;j--){ // let's find smallest j such that i can fill everything from [j,i-1]
			debt*=2;
			debt+=X;
			debt-=vec[j];
			if(debt<=0)smallest=min(smallest,j);
			if(debt>oo)break; // no way to repay
			debt=max(0ll,debt); 
		}*/
		if(smallest==i){
			ans+=vec[i]>=X;
			continue;
		}

		int sum = 0;
		for(int j=i;j>=smallest;j--){
			sum+=vec[j]<<(j-smallest);
		}
		int res=sum/X;
		res=min(res,(1ll<<(i-smallest+1))-1);
		res-=1ll<<(i-smallest);
		//debug(i,smallest,res+1);
		ans+=max(0ll,res+1);
	}
	return ans;
}
 
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -