93362024-02-20 15:08:31AblablablaSzigetek (35 pont)cpp17Accepted 35/3527ms8316 KiB
#include <bits/stdc++.h>

using namespace std;

const int INF = 2e9 + 7;

int main()
{
    int n;
    cin >> n;

    vector<int> arak(n);

    for(int i = 0; i < n; i++){
        cin >> arak[i];
    }

    vector<int> dp(n, INF);
    dp[0] = arak[0];
    for(int i = 0; i < n; i++){
        if(i + 1 < n){
            dp[i + 1] = min(dp[i] + arak[i + 1], dp[i + 1]);
        }

        if(i + 2 < n){
            dp[i + 2] = min(dp[i] + arak[i + 2], dp[i + 2]);
        }
    }

    cout << dp[n - 1] << "\n";
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1816 KiB
2Accepted0/027ms3792 KiB
3Accepted1/13ms2792 KiB
4Accepted1/13ms2768 KiB
5Accepted1/13ms3004 KiB
6Accepted1/13ms3216 KiB
7Accepted1/13ms3436 KiB
8Accepted2/23ms3692 KiB
9Accepted2/23ms3912 KiB
10Accepted2/23ms4008 KiB
11Accepted2/24ms4068 KiB
12Accepted2/24ms4016 KiB
13Accepted2/24ms4128 KiB
14Accepted2/27ms4332 KiB
15Accepted2/29ms4728 KiB
16Accepted2/214ms5184 KiB
17Accepted2/219ms5876 KiB
18Accepted2/221ms6404 KiB
19Accepted2/225ms6900 KiB
20Accepted2/225ms7512 KiB
21Accepted2/227ms8060 KiB
22Accepted2/227ms8316 KiB