From ec4f37440e3361852b89c90b67f7c7e1555c43af Mon Sep 17 00:00:00 2001 From: beurmuz Date: Fri, 12 Aug 2022 08:20:08 +0900 Subject: [PATCH] =?UTF-8?q?#18=2022.08.12=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.js | 26 ++++++++++++++++++++++++++ src/bj/silver/1/README.md | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 src/bj/silver/1/1931.js create mode 100644 src/bj/silver/1/README.md diff --git a/src/bj/silver/1/1931.js b/src/bj/silver/1/1931.js new file mode 100644 index 00000000..b2910fbf --- /dev/null +++ b/src/bj/silver/1/1931.js @@ -0,0 +1,26 @@ +'use strict'; + +const inputs = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); +const n = inputs.shift(); +const timetable = []; +inputs.forEach((v) => { + let [start, end] = v.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 element = 0; // end값을 저장할 변수 +for(let x of timetable) { + if(x[0] >= element) { + answer.push(x); + element = x[1]; + } +} +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 new file mode 100644 index 00000000..0d5d04ed --- /dev/null +++ b/src/bj/silver/1/README.md @@ -0,0 +1,4 @@ +# Silver 1 +||문제번호|문제명|응시 날짜|채점 결과|링크| +|:-:|:--:|:--:|:---:|:---:|--| +|1|1913|[회의실 배정](./1931.js)|22.08.12|한번 더 풀기||