91612024-02-16 17:16:34UVinceSzigetek (35 pont)cpp17Accepted 35/3513ms5768 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    vector<int> dp(n);
    dp[0] = v[0];
    dp[1] = v[0] + v[1];
    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 1], dp[i - 2]) + v[i];
    }
    cout << dp.back();
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1828 KiB
2Accepted0/013ms3520 KiB
3Accepted1/13ms2384 KiB
4Accepted1/13ms2496 KiB
5Accepted1/13ms2708 KiB
6Accepted1/13ms2812 KiB
7Accepted1/13ms2880 KiB
8Accepted2/23ms3116 KiB
9Accepted2/23ms3168 KiB
10Accepted2/23ms3436 KiB
11Accepted2/23ms3556 KiB
12Accepted2/23ms3520 KiB
13Accepted2/24ms3808 KiB
14Accepted2/24ms3952 KiB
15Accepted2/26ms4232 KiB
16Accepted2/28ms4684 KiB
17Accepted2/29ms4656 KiB
18Accepted2/210ms5084 KiB
19Accepted2/210ms5048 KiB
20Accepted2/212ms5084 KiB
21Accepted2/212ms5336 KiB
22Accepted2/213ms5768 KiB