정다윤 풀이
const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const [TC, ...input] = require("fs") .readFileSync(filePath) .toString() .trim() .split("\n"); // TC 개수만큼 반복 for (let i = 0; i < TC; i++) { let N = input.shift(); // case 개수만큼 잘라내기 // 1차 점수 기준으로 오름차순 정렬 let Case = input .splice(0, N) .map((c) => c.split(" ").map(Number)) .sort((a, b) => a[0] - b[0]); // 1등의 점수 let answer = 1; let top = Case[0][1]; // 1등보다 잘 본 사람만 합격 for (let i = 1; i < N; i++) { if (Case[i][1] < top) { top = Case[i][1]; answer++; } } console.log(answer); }
김민수 풀이
let input = require('fs').readFileSync(__dirname + "/../input.txt").toString().trim().split("\n"); // let input = require('fs').readFileSync("/dev/stdin").toString().trim().split("\n"); const T = Number(input[0]); let line = 1; for(let i = 0; i < T; i++) { const n = Number(input[line]); const arr = []; for(let j = line + 1; j <= line + n; j++) { arr.push(input[j].split(' ').map(Number)); } arr.sort((a, b) => a[0] - b[0]); let min = 100001; let cnt = 0; for(let j = 0; j < arr.length; j++) { if(arr[j][1] < min) { cnt += 1; min = arr[j][1]; } } console.log(cnt); line += n + 1; }
안재현 풀이
하송희 풀이
const fs = require("fs"); const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt"; let [t, ...cases] = fs.readFileSync(filePath).toString().trim().split("\n"); const makevolunteerCase = () => { let volunteerCase = []; for (k = 1; k <= +cases[0]; k++) { volunteerCase.push(cases[k].split(" ")); } cases.splice(0, +cases[0] + 1); return volunteerCase.sort((a, b) => a[0] - b[0]); }; for (i = 0; i < t; i++) { let volunteerCase = makevolunteerCase(); let doc = 0; let interview = +volunteerCase[0][1]; let pass = []; let finalPass = 1; for (j = 1; j < volunteerCase.length; j++) { if (+volunteerCase[j][1] < interview) { pass.push(volunteerCase[j]); interview = +volunteerCase[j][1]; } if (+volunteerCase[j][1] == 1) doc = +volunteerCase[j][0]; } pass.forEach((ele) => { if (+ele[0] <= doc) finalPass++; }); console.log(finalPass); }