234902026-01-23 19:12:55matemakaiJárda-L (40)cpp17Accepted 40/401ms388 KiB
#include <bits/stdc++.h>
using namespace std;

struct State {
	long long split = 0, full = 0;
};

int main() {
	int n;
	cin >> n;
	vector<State> dp(n + 1);

	dp[0].full = 1;

	for (int i = 1; i < n + 1; ++i) {
		dp[i].full += dp[i - 1].full;
		dp[i].split += dp[i - 1].split;
		dp[i].full += dp[i - 1].split;
		if (i >= 2) {
			dp[i].full += dp[i - 2].full;
			dp[i].split += dp[i - 2].full * 2; 
		}
	}

	cout << dp[n].full << endl;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms380 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms332 KiB
12Accepted3/31ms388 KiB
13Accepted3/31ms316 KiB
14Accepted3/31ms316 KiB
15Accepted3/31ms316 KiB
16Accepted3/31ms316 KiB
17Accepted3/31ms316 KiB