제출 #1186874

#제출 시각아이디문제언어결과실행 시간메모리
1186874hengliao비스킷 담기 (IOI20_biscuits)C++20
0 / 100
1095 ms328 KiB
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll, ll>
#define pb push_back

typedef long long ll;

long long count_tastiness(long long x, vector<long long> a) {
	ll k=a.size();
	ll sum=0;
	vll pw(k);
	pw[0]=1;
	for(ll i=0;i<k;i++){
		if(i!=0) pw[i]=pw[i-1]*2;
		sum+=pw[i]*a[i];
	}
	ll ans=0;
	for(ll tar=0;tar*x<=sum;tar++){
		bool good=1;
		vll b=a;
		for(ll rep=0;rep<x;rep++){
			ll lef=tar;
			for(ll i=k-1;i>=0;i--){
				ll need=lef/pw[i];
				if(b[i]>=need){
					b[i]-=need;
					lef-=pw[i]*need;
				}
				else{
					lef-=pw[i]*b[i];
					b[i]=0;
				}
			}
			if(lef>0){
				good=0;
				break;
			}
		}
		if(good){
			ans++;
		}
	}
	return ans;
}

#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...