๐ฅ Algorithm/Baekjoon
[๋ฐฑ์ค 1912๋ฒ] ์ฐ์ํฉ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon
2022. 6. 6. 17:56
728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/1912
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
rl.on('line', function (line) {
input.push(line);
if (input.length === 2) {
rl.close();
}
}).on('close', function () {
input.shift();
const numArr = input[0].split(' ').map(Number);
const DP = [];
for (let i = 0; i < numArr.length; i++) {
DP[i] = numArr[i];
if (DP[i] < DP[i - 1] + numArr[i]) {
DP[i] = DP[i - 1] + numArr[i];
}
}
console.log(Math.max(...DP));
});
728x90
๋ฐ์ํ