48782023-04-05 20:32:21CWMSzigetek (35 pont)cpp17Accepted 35/3512ms5988 KiB
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>

//upper bound >
//lower bound >=
//int index = (lower_bound(testvec.begin(), testvec.end(), num)-testvec.begin());

using namespace std;
using ll = long long;

int mod = 1000000007;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<int> vec;
    vector<int> least(n);
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        vec.push_back(a);
    }
    least[0] = vec[0];
    least[1] = vec[0] + vec[1];
    for (size_t i = 2; i < n; i++)
    {
        least[i] = min(least[i - 2], least[i - 1]) + vec[i];
    }
    cout << least[n - 1];
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1832 KiB
2Accepted0/012ms4064 KiB
3Accepted1/13ms2236 KiB
4Accepted1/13ms2440 KiB
5Accepted1/12ms2656 KiB
6Accepted1/13ms2884 KiB
7Accepted1/12ms2972 KiB
8Accepted2/23ms3088 KiB
9Accepted2/23ms3456 KiB
10Accepted2/23ms3428 KiB
11Accepted2/23ms3428 KiB
12Accepted2/23ms3756 KiB
13Accepted2/23ms4240 KiB
14Accepted2/24ms4304 KiB
15Accepted2/26ms4620 KiB
16Accepted2/27ms4976 KiB
17Accepted2/28ms5700 KiB
18Accepted2/29ms5780 KiB
19Accepted2/210ms5956 KiB
20Accepted2/210ms5944 KiB
21Accepted2/212ms5988 KiB
22Accepted2/212ms5984 KiB