답안 #602063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
602063 2022-07-22T14:25:47 Z yutabi 비스킷 담기 (IOI20_biscuits) C++14
0 / 100
2 ms 468 KB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;


#define pb push_back


typedef long long ll;





long long count_tastiness(long long x, std::vector<long long> a)
{
	ll pwr2[61];

	pwr2[0]=1;

	for(int i=1;i<61;i++)
	{
		pwr2[i]=pwr2[i-1]*2;
	}

	while(a.size()<61)
	{
		a.pb(0);
	}

	for(int i=0;i<a.size()-1;i++)
	{
		if(a[i]>x)
		{
			a[i+1]+=(a[i]-x)/2;
			a[i]-=((a[i]-x)/2)*2;
		}
	}

	vector <bool> possible(61,0);

	ll spare=0;

	for(int i=0;i<61;i++)
	{
		spare/=2;
		spare+=a[i];

		if(spare>=x)
		{
			possible[x]=1;
		}
	}

	ll ans=0;

	ll sum=0;

	vector <ll> sums;

	for(int i=0;i<61;i++)
	{
		sum+=pwr2[i]*a[i];

		sums.pb(sum);
	}

	sum=0;

	vector <ll> res;

	for(int i=0;i<61;i++)
	{
		sum+=pwr2[i]*a[i];

		if(sum>=pwr2[i]*x)
		{
			ll nw_sum=sum-pwr2[i]*x;
			ll nw_res;

			if(i==0)
			{
				nw_res=1;
			}

			else
			{
				nw_res=res.back()+1;
			}

			for(int j=i-1;j>=0;j--)
			{
				nw_sum=min(sums[j],nw_sum);

				if(nw_sum>=x*pwr2[j])
				{
					nw_res+=res[j];

					nw_sum-=x*pwr2[j];
				}
			}

			res.pb(nw_res);
		}

		else
		{
			if(i==0)
			{
				res.pb(0);
			}

			else
			{
				res.pb(res.back());
			}
		}
	}


	return res.back()+1;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i=0;i<a.size()-1;i++)
      |              ~^~~~~~~~~~~
biscuits.cpp:55:5: warning: unused variable 'ans' [-Wunused-variable]
   55 |  ll ans=0;
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -