Skip to content

Commit 4a33725

Browse files
Merge pull request #677 from eric-hjh/main
[황장현] 102차 라이브 코테 제출
2 parents 0a3a3c7 + 61a5099 commit 4a33725

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const input = +require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim();
5+
6+
function solution(input) {
7+
const n = input;
8+
const dp = Array(n + 1).fill(0);
9+
10+
dp[1] = 1;
11+
dp[2] = 3;
12+
13+
for (let i = 3; i <= n; i++) {
14+
dp[i] = (dp[i - 1] + 2 * dp[i - 2]) % 10007;
15+
}
16+
17+
return dp[n];
18+
}
19+
20+
console.log(solution(input));
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map((el) => el.split(' ').map(Number));
7+
8+
function solution(input) {
9+
const N = input[0][0];
10+
const an = input[1];
11+
12+
let current = an[0];
13+
let maxProfit = 0;
14+
15+
for (const a of an) {
16+
maxProfit = Math.max(maxProfit, a - current);
17+
18+
current = Math.min(current, a);
19+
}
20+
21+
return maxProfit;
22+
}
23+
24+
console.log(solution(input));

0 commit comments

Comments
 (0)