57242023-09-10 01:43:34TomaSajtSzigetek (35 pont)cpp17Accepted 35/3512ms8628 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0), cin.sync_with_stdio(0);

  int n;
  cin >> n;

  vector<int> costs(n);
  for (int& a : costs) cin >> a;

  vector<int> dp(n);
  dp[0] = costs[0];
  dp[1] = dp[0] + costs[1];

  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i - 2], dp[i - 1]) + costs[i];
  }

  cout << dp.back();
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms2100 KiB
2Accepted0/012ms3888 KiB
3Accepted1/12ms2640 KiB
4Accepted1/13ms2852 KiB
5Accepted1/13ms3088 KiB
6Accepted1/12ms3176 KiB
7Accepted1/13ms3384 KiB
8Accepted2/23ms3616 KiB
9Accepted2/23ms3984 KiB
10Accepted2/23ms4228 KiB
11Accepted2/23ms4128 KiB
12Accepted2/23ms4416 KiB
13Accepted2/23ms4636 KiB
14Accepted2/24ms4996 KiB
15Accepted2/24ms5260 KiB
16Accepted2/27ms5684 KiB
17Accepted2/28ms6080 KiB
18Accepted2/29ms6732 KiB
19Accepted2/210ms7340 KiB
20Accepted2/212ms7700 KiB
21Accepted2/212ms8172 KiB
22Accepted2/212ms8628 KiB