Submission #824880

#TimeUsernameProblemLanguageResultExecution timeMemory
824880fatemetmhrPacking Biscuits (IOI20_biscuits)C++17
42 / 100
20 ms852 KiB
// Be name khoda //

#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

#define debug(x) cerr << "(" << #x << "):" << x << endl;
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second
#define pb       push_back
#define mp       make_pair

typedef long long ll;

const int maxn5 = 1e4 + 10; 

ll dp[2][maxn5];


long long count_tastiness(long long x, std::vector<long long> a) {
	int k = 60;
	while(a.size() < k)
		a.pb(0);
	ll ans = 1;
	int ind = 0;
	while(ind < k){
		if(a[ind] >= x + 2){
			a[ind + 1] += (a[ind] - x) / 2;
			a[ind] -= ((a[ind] - x) / 2) * 2;
		}
		//if(a[ind]) cout << ind << ' ' << a[ind] << endl;
		ind++;
	}
	k = a.size();
	memset(dp, 0, sizeof dp);
	dp[1][0] = 1;
	for(int i = 0; i < k; i++){
		fill(dp[i&1], dp[i&1] + maxn5, 0);
		for(int j = 0; j < maxn5; j++){
			dp[i&1][(j + a[i]) / 2] += dp[(i&1)^1][j];
			if(j + a[i] >= x){
				ans += dp[(i&1)^1][j];
				
				dp[i&1][(j + a[i] - x) / 2] += dp[(i&1)^1][j];
			}
		}
	}
	return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:24:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |  while(a.size() < k)
      |        ~~~~~~~~~^~~
#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...