Submission #332191

#TimeUsernameProblemLanguageResultExecution timeMemory
332191pggpPacking Biscuits (IOI20_biscuits)C++14
0 / 100
1102 ms128748 KiB
#include <bits/stdc++.h>

using namespace std;

long long count_tastiness(long long x, vector < long long > k){
	k.resize(62);
	for (int i = 0; i < k.size() - 1; ++i)
	{
		if(k[i] > x){
			k[i + 1] += (k[i] - x)/2;
			k[i] -= 2 * ((k[i] - x)/2);
		}
		//cout << "k: " << k[i] << endl;
	}
	int DP[2 * x + 2];
	int DP1[2 * x + 2];
	for (int j = 0; j < 2 * x + 2; ++j)
	{
		DP[j] = DP1[j] = 0; 
	}
	DP[k[0]] = 1;
	for (int i = 0; i < k.size() - 1; ++i)
	{
		// używamy x
		for (int j = 0; j < 2 * x + 2 and k[i + 1] + (j - x) / 2 < 2 * x + 2; ++j)
		{
			if(j >= x){
				DP1[k[i + 1] + (j - x) / 2] += DP[j]; 
			}
		}

		// nie używamy x

		for (int j = 0; j < 2 * x + 2 and k[i + 1] + j / 2 < 2 * x + 2; ++j)
		{
			DP1[k[i + 1] + j / 2] += DP[j]; 
		}

		for (int j = 0; j < 2 * x + 2; ++j)
		{
			//cout << DP1[j] << " "; 
		}

		for (int j = 0; j < 2 * x + 2; ++j)
		{
			DP[j] = DP1[j]; 
			DP1[j] = 0;
		}

		
		//cout << endl;
	}

	long long sum = 0;
	for (int i = 0; i < 2 * x + 1; ++i)
	{
		sum += DP[i];
	}
	return sum;
}

Compilation message (stderr)

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