제출 #432416

#제출 시각아이디문제언어결과실행 시간메모리
432416Mlxa비스킷 담기 (IOI20_biscuits)C++14
33 / 100
1081 ms129484 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "biscuits.h"

bool bit(ll m, int i) {
	return (m >> i) & 1;
}

ll count_tastiness(ll x, vector<ll> a) {
	a.resize(200, 0);
	for (int i = 0; i < 150; ++i) {
		ll carry = max(0LL, (a[i] - x) / 2);
		a[i + 1] += carry;
		a[i] -= 2 * carry;
	}
	assert(*max_element(all(a)) <= x + 1);
	reverse(all(a));
	vector<ll> dp(x + 1, 0);
	dp[0] = 1, dp[x] = 1;
	for (ll h : a) {
		// cout << "h = " << h << endl;
		vector<ll> np(x + 1, 0);
		for (ll k = 0; k <= x; ++k) {
			// place 0
			if (2 * k - h <= x) {
				np[max(0LL, 2 * k - h)] += dp[k];
			}
			// place 1
			if (2 * k - h <= 0) {
				np[max(0LL, 2 * k - h + x)] += dp[k];
			}
		}
		dp = np;
		// for (ll e : dp) {
		// 	cout << e << " ";
		// }
		// cout << endl;
	}
	return dp[0];
}

#ifdef LC
#include "grader.cpp"
#endif
#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...