Skip to content

Commit

Permalink
#18 22.08.13 > 1 > 회의실 배정
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Aug 13, 2022
1 parent ec4f374 commit fffcef5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/bj/silver/1/1931_re.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion src/bj/silver/1/README.md
Original file line number Diff line number Diff line change
@@ -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)||

0 comments on commit fffcef5

Please sign in to comment.