48802023-04-05 21:42:33SleepyOverlordSzigetek (35 pont)cpp17Accepted 35/3527ms5836 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

int n;
VI a, dp;

int main()
{
	cin >> n;
	a.RS(n + 1);
	dp.RS(n + 1);
	FOR(i, 1, n) cin >> a[i];

	dp[1] = a[1];
	dp[2] = a[1] + a[2];
	FOR(i, 3, n) dp[i] = a[i] + min(dp[i - 1], dp[i - 2]);
	cout << dp[n];
	
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1876 KiB
2Accepted0/027ms3424 KiB
3Accepted1/13ms2300 KiB
4Accepted1/13ms2540 KiB
5Accepted1/13ms2740 KiB
6Accepted1/13ms3224 KiB
7Accepted1/13ms3036 KiB
8Accepted2/23ms3168 KiB
9Accepted2/23ms3068 KiB
10Accepted2/23ms3200 KiB
11Accepted2/23ms3292 KiB
12Accepted2/24ms3304 KiB
13Accepted2/24ms3596 KiB
14Accepted2/27ms3764 KiB
15Accepted2/29ms4180 KiB
16Accepted2/214ms4604 KiB
17Accepted2/218ms4992 KiB
18Accepted2/221ms5332 KiB
19Accepted2/224ms5596 KiB
20Accepted2/224ms5548 KiB
21Accepted2/226ms5712 KiB
22Accepted2/226ms5836 KiB