Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8c3388
commit abb6eb6
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |