85052024-01-19 16:37:55zeytonxSzigetek (35 pont)cpp17Accepted 35/3513ms8832 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pll pair<long, long>
#define endl "\n"
#define first fs
#define second sc
#define vll vector<ll>

void solve()
{
	ll n;
	cin >> n;
	vll a(n);
	for(ll i = 0; i < n; i++) 
		cin >> a[i];
	vll dp(n);
	dp[0] = a[0];
	dp[1] = a[0]+a[1];
	for(ll i = 2; i < n; i++)
		dp[i] = min(dp[i-1]+a[i], dp[i-2]+a[i]);
	cout << dp[n-1] << endl;
}

int main() 
{
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	ll t = 1;
	//cin >> t;
	while(t--) solve();
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1824 KiB
2Accepted0/013ms5472 KiB
3Accepted1/13ms2656 KiB
4Accepted1/13ms2744 KiB
5Accepted1/12ms2736 KiB
6Accepted1/13ms2868 KiB
7Accepted1/13ms3080 KiB
8Accepted2/23ms3444 KiB
9Accepted2/23ms3676 KiB
10Accepted2/23ms3636 KiB
11Accepted2/23ms3924 KiB
12Accepted2/23ms4108 KiB
13Accepted2/23ms4116 KiB
14Accepted2/24ms4412 KiB
15Accepted2/26ms4924 KiB
16Accepted2/28ms5532 KiB
17Accepted2/29ms6520 KiB
18Accepted2/210ms7152 KiB
19Accepted2/210ms7584 KiB
20Accepted2/212ms8184 KiB
21Accepted2/213ms8808 KiB
22Accepted2/213ms8832 KiB