From fffcef5c77f4bcec193db4ff86af431ab6ec20b1 Mon Sep 17 00:00:00 2001 From: beurmuz Date: Sat, 13 Aug 2022 13:39:06 +0900 Subject: [PATCH] =?UTF-8?q?#18=2022.08.13=20>=201=20>=20=ED=9A=8C=EC=9D=98?= =?UTF-8?q?=EC=8B=A4=20=EB=B0=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bj/silver/1/1931_re.js | 28 ++++++++++++++++++++++++++++ src/bj/silver/1/README.md | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/bj/silver/1/1931_re.js diff --git a/src/bj/silver/1/1931_re.js b/src/bj/silver/1/1931_re.js new file mode 100644 index 00000000..ded3cdc2 --- /dev/null +++ b/src/bj/silver/1/1931_re.js @@ -0,0 +1,28 @@ +'use strict'; + +const inputs = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); +const n = inputs.shift(); +let timeTable = []; +inputs.forEach((line) => { + let [start, end] = line.split(' '); + timeTable.push([+start, +end]); +}); + +timeTable.sort((a, b)=> { + if(a[1] === b[1]) { + return a[0]-b[0]; + } + return a[1]-b[1]; +}); + + +const answer = []; +let endTime = 0; +for(let [start, end] of timeTable) { + if(start >= endTime) { // 현재 시간이, 그 전 endTime보다 크거나 같다면 + answer.push([start, end]); + endTime = end; + } +} + +console.log(answer.length); \ No newline at end of file diff --git a/src/bj/silver/1/README.md b/src/bj/silver/1/README.md index 0d5d04ed..04a8af7c 100644 --- a/src/bj/silver/1/README.md +++ b/src/bj/silver/1/README.md @@ -1,4 +1,4 @@ # Silver 1 ||문제번호|문제명|응시 날짜|채점 결과|링크| |:-:|:--:|:--:|:---:|:---:|--| -|1|1913|[회의실 배정](./1931.js)|22.08.12|한번 더 풀기|| +|1|1913|[회의실 배정](./1931.js)|22.08.12|[22.08.13](./1931_re.js)||