144692025-01-10 22:38:10MonikaJárda-L (40)cpp17Accepted 40/401ms508 KiB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int h;
    cin >> h;
    vector<int> A(h+1);
    vector<int> B(h+1);
    A[1] = 1;
    A[2] = 2;
    B[1] = 0;
    B[2] = 1;

    for (int i = 3; i <= h; i++)
    {
        A[i] = A[i-1] + A[i-2] + 2*B[i-1];
        B[i] = A[i-2] + B[i-1];
    }
    cout << A[h] << "\n";



}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms508 KiB
7Accepted2/21ms500 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Accepted3/31ms316 KiB
13Accepted3/31ms316 KiB
14Accepted3/31ms316 KiB
15Accepted3/31ms316 KiB
16Accepted3/31ms316 KiB
17Accepted3/31ms316 KiB