83992024-01-15 15:35:14Balki22Szigetek (35 pont)cpp17Accepted 35/3527ms5136 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

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

	vector<int> dp(n+1);
	dp[0] = cost[0];
	dp[1] = cost[0] + cost[1]; 
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1], dp[i-2]) + cost[i];
		// cerr << dp[i] << endl;
	}
	cout << dp[n-1];
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1820 KiB
2Accepted0/026ms3432 KiB
3Accepted1/13ms2188 KiB
4Accepted1/13ms2396 KiB
5Accepted1/13ms2624 KiB
6Accepted1/13ms2556 KiB
7Accepted1/13ms2796 KiB
8Accepted2/23ms3056 KiB
9Accepted2/23ms3088 KiB
10Accepted2/23ms3140 KiB
11Accepted2/24ms3280 KiB
12Accepted2/24ms3368 KiB
13Accepted2/24ms3404 KiB
14Accepted2/27ms3760 KiB
15Accepted2/29ms3688 KiB
16Accepted2/214ms4196 KiB
17Accepted2/219ms4416 KiB
18Accepted2/221ms4912 KiB
19Accepted2/224ms4840 KiB
20Accepted2/224ms4968 KiB
21Accepted2/226ms5136 KiB
22Accepted2/227ms5136 KiB