From d9d20c00dbbb839c6f51e37960bce1bd6ca9f55f Mon Sep 17 00:00:00 2001 From: beurmuz Date: Sun, 14 Aug 2022 14:10:05 +0900 Subject: [PATCH] =?UTF-8?q?#18=2022.08.14=20>=202=20>=20=EC=97=B0=EC=86=8D?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bj/silver/2/1912_re.js | 19 +++++++++++++++++++ src/bj/silver/2/README.md | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/bj/silver/2/1912_re.js diff --git a/src/bj/silver/2/1912_re.js b/src/bj/silver/2/1912_re.js new file mode 100644 index 00000000..697f8958 --- /dev/null +++ b/src/bj/silver/2/1912_re.js @@ -0,0 +1,19 @@ +'use strict'; + +const input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); +const n = input.shift()*1; +const progression = (''+input).split(' ').map(v => +v); + +const dp = Array(n).fill(0); +dp[0] = progression[0]; +let max = dp[0]; + +for(let i = 1; i <= n; i++) { + let item = progression[i]+dp[i-1]; + if(item > max) { + dp[i] = item; + max = item; + } +} + +console.log(Math.max(...dp)); \ No newline at end of file diff --git a/src/bj/silver/2/README.md b/src/bj/silver/2/README.md index 85c68c5e..167acbf5 100644 --- a/src/bj/silver/2/README.md +++ b/src/bj/silver/2/README.md @@ -2,6 +2,6 @@ ||문제번호|문제명|응시 날짜|채점 결과|링크| |:-:|:--:|:--:|:---:|:---:|--| |1|1012|[유기농 배추](./1012.js)|22.08.06|X|[아직]()| -|2|1260|[DFS와 BFS](./1260.js)|22.08.08|[22.08.13](./1138_re.js)|[참고사이트](https://cider.tistory.com/4)| -|3|1138|[한 줄로 서기](./1138.js)|22.08.09|X| -|4|1912|[연속합](./1912.js)|22.08.10|X| \ No newline at end of file +|2|1260|[DFS와 BFS](./1260.js)|22.08.08|다시!|[참고사이트](https://cider.tistory.com/4)| +|3|1138|[한 줄로 서기](./1138.js)|22.08.09|[22.08.13](./1138_re.js)| +|4|1912|[연속합](./1912.js)|22.08.10|[22.08.14](./1912_re.js)| \ No newline at end of file