17022022-12-01 16:14:35kovacs.peter.18fJárda-L (40)cpp11Accepted 40/403ms3676 KiB
#include <iostream>
#include <vector>

using namespace std;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    if (N < 2) {
        cout << "1\n";
        return 0;
    }
    vector<long long> halfS(N + 1), fullS(N + 1);
    fullS[0] = fullS[1] = 1;
    fullS[2] = halfS[2] = 2;
    for (int i = 3; i <= N; i++) {
        halfS[i] = halfS[i - 1] + fullS[i - 2] * 2;
        fullS[i] = fullS[i - 1] + fullS[i - 2] + halfS[i - 1];
    }
    cout << fullS[N] << '\n';
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1700 KiB
2Accepted0/02ms1864 KiB
3Accepted2/22ms2068 KiB
4Accepted2/22ms2272 KiB
5Accepted2/22ms2472 KiB
6Accepted2/22ms2712 KiB
7Accepted2/22ms2752 KiB
8Accepted3/32ms2756 KiB
9Accepted3/32ms2760 KiB
10Accepted3/32ms2992 KiB
11Accepted3/32ms2956 KiB
12Accepted3/32ms3204 KiB
13Accepted3/32ms3316 KiB
14Accepted3/32ms3368 KiB
15Accepted3/32ms3468 KiB
16Accepted3/32ms3596 KiB
17Accepted3/32ms3676 KiB