87332024-01-26 20:13:03bovizdbSzigetek (35 pont)cpp17Accepted 35/3528ms7724 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	vector<int>dp(n);
	dp[0] = v[0];
	dp[1] = v[0]+v[1];
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i-1], dp[i-2]) + v[i];
	}
	cout << dp[n-1];
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1812 KiB
2Accepted0/028ms3744 KiB
3Accepted1/13ms2880 KiB
4Accepted1/13ms2796 KiB
5Accepted1/13ms3016 KiB
6Accepted1/12ms3096 KiB
7Accepted1/13ms3120 KiB
8Accepted2/23ms3112 KiB
9Accepted2/23ms3120 KiB
10Accepted2/23ms3456 KiB
11Accepted2/24ms3812 KiB
12Accepted2/24ms3948 KiB
13Accepted2/24ms4172 KiB
14Accepted2/27ms4224 KiB
15Accepted2/29ms4496 KiB
16Accepted2/214ms4956 KiB
17Accepted2/220ms5416 KiB
18Accepted2/223ms6088 KiB
19Accepted2/226ms6528 KiB
20Accepted2/226ms7020 KiB
21Accepted2/228ms7340 KiB
22Accepted2/228ms7724 KiB