Skip to content

Commit

Permalink
#18 22.08.12 > 1 > 회의실 배정
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Aug 11, 2022
1 parent 497ce1e commit ec4f374
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/bj/silver/1/1931.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 4 additions & 0 deletions src/bj/silver/1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Silver 1
||문제번호|문제명|응시 날짜|채점 결과|링크|
|:-:|:--:|:--:|:---:|:---:|--|
|1|1913|[회의실 배정](./1931.js)|22.08.12|한번 더 풀기||

0 comments on commit ec4f374

Please sign in to comment.