216122026-01-13 17:10:58algoproSzigetek (35 pont)cpp17Accepted 35/3525ms1260 KiB
// UUID: 06d3c9eb-905d-4324-8d60-34a27fdf7957
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;

	vector <int> szigetek(n);
	vector <int> dp(n);

	for(int i = 0; i < n; i++)
		cin >> szigetek[i];

	dp[0] = szigetek[0];
	dp[1] = szigetek[1] + szigetek[0];

	for(int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + szigetek[i], dp[i - 2] + szigetek[i]);
	}
	cout << dp[n - 1];
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/01ms316 KiB
2Accepted0/025ms1260 KiB
3Accepted1/11ms508 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms316 KiB
10Accepted2/22ms316 KiB
11Accepted2/22ms316 KiB
12Accepted2/22ms316 KiB
13Accepted2/23ms316 KiB
14Accepted2/24ms572 KiB
15Accepted2/28ms636 KiB
16Accepted2/213ms804 KiB
17Accepted2/217ms820 KiB
18Accepted2/219ms820 KiB
19Accepted2/220ms1076 KiB
20Accepted2/221ms1116 KiB
21Accepted2/224ms1076 KiB
22Accepted2/224ms1196 KiB