We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0415cae commit 7540acbCopy full SHA for 7540acb
이용훈/11주차/260310.js
@@ -0,0 +1,15 @@
1
+const fs = require('fs');
2
+const lines = fs.readFileSync(0, 'utf8').trim().split('\n');
3
+
4
+const input = lines.map(line => Number(line));
5
+const n = input.shift();
6
7
+const dy = Array.from({ length: n + 1 }, () => 0);
8
+dy[1] = input[0];
9
+dy[2] = input[0] + input[1];
10
11
+for(let i = 3; i < n + 1; i++) {
12
+ dy[i] = Math.max(dy[i - 2] + input[i - 1], dy[i - 3] + input[i - 2] + input[i - 1]);
13
+}
14
15
+console.log(dy[n]);
0 commit comments