36092023-03-01 10:12:14UnluckYJárda-L (40)cpp11Accepted 40/403ms3928 KiB

#include <bits/stdc++.h>

using namespace std;

int main(){


    int n; cin >> n;

     // dp(n) = dp(n-1) + dp(n-2) + 2*dp(n-3) + 2*dp(n-4)

     vector<int> dp = {1, 1, 2};

     for (int i = 3; i <= n; i++){
        int x = dp[i-1] + dp[i-2];
        for (int j = i-3; j >= 0; j--) x += 2*dp[j];
        dp.push_back(x);
     }

     cout << dp[n];










    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1888 KiB
2Accepted0/03ms2020 KiB
3Accepted2/23ms2100 KiB
4Accepted2/23ms2232 KiB
5Accepted2/23ms2444 KiB
6Accepted2/23ms2652 KiB
7Accepted2/23ms2768 KiB
8Accepted3/33ms2864 KiB
9Accepted3/33ms3084 KiB
10Accepted3/33ms3288 KiB
11Accepted3/33ms3500 KiB
12Accepted3/33ms3592 KiB
13Accepted3/33ms3592 KiB
14Accepted3/33ms3844 KiB
15Accepted3/33ms3928 KiB
16Accepted3/33ms3812 KiB
17Accepted3/32ms3808 KiB