121922024-12-07 16:33:26gkataJárda-L (40)cpp17Accepted 40/401ms592 KiB
#include <iostream>
#include <vector>

using namespace std;

int n,i;
vector<int>a;
vector<int>b;

int main()
{
    cin>>n;

    a.resize(n+1);
    b.resize(n+1);

    a[1]=1;
    a[2]=2;
    b[1]=0;
    b[2]=1;

    for(i=3;i<=n;++i)
    {
        a[i]=a[i-1]+a[i-2]+2*b[i-1];
        b[i]=a[i-2]+b[i-1];
    }

    cout<<a[n];

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