8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc4ebf8 commit 20c8d31Copy full SHA for 20c8d31
0x10/2579_2.cpp
@@ -0,0 +1,27 @@
1
+// http://boj.kr/e93e56bb850a46378cf8f53486233cdc
2
+#include <bits/stdc++.h>
3
+using namespace std;
4
+
5
+int s[305];
6
+int n;
7
+int d[305];
8
9
+int main(void){
10
+ ios::sync_with_stdio(0);
11
+ cin.tie(0);
12
+ cin >> n;
13
+ int tot = 0;
14
+ for(int i = 1; i <= n; i++){
15
+ cin >> s[i];
16
+ tot += s[i];
17
+ }
18
+ if(n <= 2){
19
+ cout << tot;
20
+ return 0;
21
22
+ d[1] = s[1];
23
+ d[2] = s[2];
24
+ d[3] = s[3];
25
+ for(int i = 4; i <= n-1; i++) d[i] = min(d[i-2],d[i-3])+s[i];
26
+ cout << tot - min(d[n-1],d[n-2]);
27
+}
0 commit comments