83952024-01-15 15:32:30Balki22Szigetek (35 pont)cpp17Time limit exceeded 21/35300ms7344 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] + cost[i], dp[i-2] + cost[i]);
		cerr << dp[i] << endl;
	}
	cout << dp[n-1];
}
SubtaskSumTestVerdictTimeMemory
base21/35
1Accepted0/03ms1816 KiB
2Time limit exceeded0/0300ms2480 KiB
3Accepted1/13ms2504 KiB
4Accepted1/13ms2708 KiB
5Accepted1/13ms2944 KiB
6Accepted1/13ms2872 KiB
7Accepted1/13ms3152 KiB
8Accepted2/24ms3256 KiB
9Accepted2/28ms3444 KiB
10Accepted2/213ms3588 KiB
11Accepted2/214ms3672 KiB
12Accepted2/220ms3876 KiB
13Accepted2/235ms4108 KiB
14Accepted2/270ms4464 KiB
15Accepted2/289ms4592 KiB
16Time limit exceeded0/2212ms5272 KiB
17Time limit exceeded0/2254ms5800 KiB
18Time limit exceeded0/2261ms5080 KiB
19Time limit exceeded0/2261ms5588 KiB
20Time limit exceeded0/2270ms7344 KiB
21Time limit exceeded0/2248ms6456 KiB
22Time limit exceeded0/2264ms6708 KiB