94582024-02-21 22:31:49Vkrisztian01Szigetek (35 pont)cpp11Accepted 35/3528ms5796 KiB
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int n;
vector<int>arak;
vector<pair<int,int> > dp;

int main()
{
    cin>>n;
    arak.resize(n+1);
    dp.resize(n+1);
    for(int i=1;i<=n;i++)  cin>>arak[i];
    dp[1]=make_pair(arak[1],arak[1]);
    for(int i=2;i<=n;i++)
    {
        dp[i].first=min(dp[i-1].first,dp[i-1].second)+arak[i];
        dp[i].second=dp[i-1].first;
    }
    /*cout<<endl;
    for(int i=1;i<=n;i++) cout<<dp[i].first<<" ";
    cout<<endl;
    for(int i=1;i<=n;i++) cout<<dp[i].second<<" ";*/
        cout<<dp[n].first;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1880 KiB
2Accepted0/028ms4328 KiB
3Accepted1/13ms2280 KiB
4Accepted1/13ms2488 KiB
5Accepted1/12ms2576 KiB
6Accepted1/12ms2572 KiB
7Accepted1/13ms2604 KiB
8Accepted2/23ms2684 KiB
9Accepted2/23ms2700 KiB
10Accepted2/23ms2836 KiB
11Accepted2/23ms2936 KiB
12Accepted2/24ms2944 KiB
13Accepted2/24ms3264 KiB
14Accepted2/27ms3560 KiB
15Accepted2/29ms4144 KiB
16Accepted2/214ms4412 KiB
17Accepted2/219ms4876 KiB
18Accepted2/223ms5264 KiB
19Accepted2/225ms5396 KiB
20Accepted2/226ms5392 KiB
21Accepted2/228ms5796 KiB
22Accepted2/228ms5796 KiB