94872024-02-22 11:23:30AGergoSzigetek (35 pont)cpp17Accepted 35/3513ms4896 KiB
#include <bits/stdc++.h>

using namespace std;

int n;
vector<int> price;
vector<int> lowestPrice; // lowest price to get to any island

int main()
{
    cin.tie(0);ios::sync_with_stdio(0);
    cin >> n;
    price.resize(n+1);
    lowestPrice.resize(n+1,INT_MAX);

    for(int i = 0; i < n; i++)
    {
        cin >> price[i+1];
    }
    lowestPrice[1] = price[1];
    lowestPrice[2] = price[1]+price[2];
    for(int i = 3; i < n+1;i++)
    {
        lowestPrice[i] = min(lowestPrice[i-1],lowestPrice[i-2])+price[i];
    }

//    bejar(1,price[1]);
    cout << lowestPrice[n];
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1892 KiB
2Accepted0/013ms3580 KiB
3Accepted1/13ms2336 KiB
4Accepted1/13ms2508 KiB
5Accepted1/13ms2732 KiB
6Accepted1/13ms2944 KiB
7Accepted1/13ms3164 KiB
8Accepted2/23ms3260 KiB
9Accepted2/23ms3264 KiB
10Accepted2/23ms3268 KiB
11Accepted2/23ms3260 KiB
12Accepted2/23ms3468 KiB
13Accepted2/23ms3404 KiB
14Accepted2/24ms3592 KiB
15Accepted2/26ms3912 KiB
16Accepted2/28ms4228 KiB
17Accepted2/29ms4352 KiB
18Accepted2/210ms4744 KiB
19Accepted2/212ms4896 KiB
20Accepted2/212ms4796 KiB
21Accepted2/213ms4876 KiB
22Accepted2/213ms4872 KiB