Submission #1207962

#TimeUsernameProblemLanguageResultExecution timeMemory
1207962CyanmondPacking Biscuits (IOI20_biscuits)C++20
Compilation error
0 ms0 KiB
#include "biscuits.h"

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

long long count_tastiness(long long x, std::vector<long long> a) {
	for (int i = 0; i < int(a.size()); ++i) {
		if (a[i] > x + 1) {
			ll diff = a[i] - (x + 1);
			ll div = (diff + 1) / 2;
			a[i] -= div * 2;
			if (i == int(a.size()) - 1) {
				a.push_back(0);
			}
			a[i + 1] += div;
		}
	}
	a.push_back(0);

	reverse(a, a + n + 1);
	int n = int(a.size());
	vector<ll> dp(n + 1, 0ll);
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		// case 1: no
		dp[i + 1] += dp[i];
		// case 2: yes
		if (a[i] >= x) {
			dp[i + 1] += dp[i];
			continue;
		}

		ll lack = x;
		for (int j = i; j < n; ++j) {
			lack -= a[j];
			if (lack <= 0) {
				dp[j + 1] += dp[i];
				lack += x;
			}
			lack *= 2;
			if (lack > 5 * x) {
				break;
			}
		}
	}

	return dp[n];
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:26:24: error: 'n' was not declared in this scope
   26 |         reverse(a, a + n + 1);
      |                        ^