Skip to content

Commit

Permalink
11-신입-사원
Browse files Browse the repository at this point in the history
  • Loading branch information
minbr0ther committed Feb 23, 2022
1 parent e8c3388 commit abb6eb6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 2022/greedy/11-신입-사원/app.js
@@ -0,0 +1,34 @@
const fs = require("fs");
const filePath =
process.platform === "linux"
? "/dev/stdin"
: "/Users/jeongminhyeong/boj/2022/greedy/11-신입-사원/input.txt";
let input = fs.readFileSync(filePath).toString().trim().split("\n");

const N = input.shift();
const testCase = {};
let key = "";
input.forEach((str) => {
if (str.length === 1) {
key = str;
testCase[key] = [];
} else {
testCase[key].push(str.split(" ").map(Number));
}
});

Object.values(testCase).forEach((arr) => {
arr.sort((a, b) => a[0] - b[0]);

let minRank = arr[0][1];
let cnt = 1;
for (let i = 0; i < arr.length; i++) {
const rank = arr[i][1];

if (rank < minRank) {
minRank = rank;
cnt += 1;
}
}
console.log(cnt);
});
15 changes: 15 additions & 0 deletions 2022/greedy/11-신입-사원/input.txt
@@ -0,0 +1,15 @@
2
5
3 2
1 4
4 1
2 3
5 5
7
3 6
7 3
4 2
1 4
5 7
2 5
6 1

0 comments on commit abb6eb6

Please sign in to comment.