Submission #653288

#TimeUsernameProblemLanguageResultExecution timeMemory
653288mychecksedad비스킷 담기 (IOI20_biscuits)C++17
9 / 100
45 ms352 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
 
int n;
ll count_tastiness(ll x, vector<ll> a){
	n = 61;
	for(int i = 0; i < n-a.size(); ++i) a.pb(0);
	ll ans = 0;
	int sum = 0;
	for(int i = 0; i < min(n, 62); ++i) sum += (1ll<<i) * a[i];
 
	if(sum/x <= 100000){
		for(ll y = 0; y <= sum / x; ++y){
			ll c = 0;
			bool ok = 1;
			for(ll j = 0; j < n; ++j){
				if((1ll<<j)&y){		
					c += a[j];
					if(c<x){
						ok = 0;
						break;
					}
					c-=x;
				}else{
					c += a[j];
				}
				c >>= 1;
			}
			if(ok) ans++;
		}
		return ans;
	}else{
		vector<ll> b = a;
		for(int i = 0; i < n - 1; ++i){
			if(b[i] > 1) b[i + 1] += (b[i]-1)/2;
		}
		ll ans = 1;
		for(int i = 0; i < n - 1; ++i) if(b[i]>0) ans *= 2;
		return ans;
	}
	return ans;
}	

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < n-a.size(); ++i) a.pb(0);
      |                 ~~^~~~~~~~~~~~
#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...