85352024-01-21 15:53:12gergomiszoriSzigetek (35 pont)cpp17Accepted 35/3513ms9048 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/03ms2100 KiB
2Accepted0/013ms5584 KiB
3Accepted1/13ms2764 KiB
4Accepted1/13ms2768 KiB
5Accepted1/13ms2788 KiB
6Accepted1/13ms2932 KiB
7Accepted1/13ms3144 KiB
8Accepted2/23ms3268 KiB
9Accepted2/23ms3624 KiB
10Accepted2/23ms3908 KiB
11Accepted2/23ms4232 KiB
12Accepted2/23ms4084 KiB
13Accepted2/24ms4544 KiB
14Accepted2/24ms4872 KiB
15Accepted2/26ms5456 KiB
16Accepted2/28ms6132 KiB
17Accepted2/29ms7116 KiB
18Accepted2/210ms7620 KiB
19Accepted2/212ms7864 KiB
20Accepted2/212ms8060 KiB
21Accepted2/213ms8660 KiB
22Accepted2/213ms9048 KiB