Submission #306208

# Submission time Handle Problem Language Result Execution time Memory
306208 2020-09-24T21:03:02 Z vincent97198 Packing Biscuits (IOI20_biscuits) C++14
0 / 100
1000 ms 512 KB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

int ans=0;
const int DEP=60;

bool dfs(long long sum,long long dep,long long x,vector<long long> a)
{
	if(dep==0 || sum<=0){
		if(sum>=x)	return true;
		else{
			++ans;
			return false;
		}
	}

	if(sum>=x*(1LL<<dep)){
		bool flag=dfs(sum-max(x,a[dep])*(1LL<<dep),dep-1,x,a);
		if(flag)	return flag;
	}
	bool flag=dfs(sum-a[dep]*(1LL<<dep),dep-1,x,a);
	if(flag)
		ans+=(1LL<<dep);
	return false;

}

long long count_tastiness(long long x, std::vector<long long> a)
{
	ans=0;
	while(a.size()!=DEP)	a.push_back(0);
	long long sum=0;
	for(long long i=0;i<a.size();++i)	sum+=a[i]*(1LL<<i);
	if(dfs(sum,DEP-1,x,a))	ans+=(1LL<<DEP);
	return ans;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:35:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(long long i=0;i<a.size();++i) sum+=a[i]*(1LL<<i);
      |                    ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Execution timed out 1098 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 1 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Execution timed out 1098 ms 384 KB Time limit exceeded
3 Halted 0 ms 0 KB -