문제
https://www.acmicpc.net/problem/7568
7568번: 덩치
우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x, y)로 표시된다. 두 사람 A 와 B의 덩
www.acmicpc.net
문제 풀이
해당 문제의 입력의 최대 개수는 50이다. 즉 브루트 포스로 간단하게 풀이하였다.
const fs = require('fs');
const stdin = (process.platform === 'linux'? fs.readFileSync('/dev/stdin').toString() :
``).split('\n');
const input = (() => {
let line = 0;
return () => stdin[line++];
})();
const n = Number(input());
let answer = Array(n).fill(0);
let people = [];
for(let i = 0; i < n; i++) people.push(input().split(' ').map(Number).concat(i))
for(let i = 0; i < n; i++){
let rank = 1;
for(let j = 0; j < n; j++){
if(i === j) continue;
if(people[i][0] < people[j][0] && people[i][1] < people[j][1]) rank++;
}
answer[i] = rank;
}
console.log(answer.join(' ').trim());
'algorithm > problems' 카테고리의 다른 글
[백준] 1003번 피보나치 함수 _ Node.js (0) | 2022.11.20 |
---|---|
[백준] 18111번 마인크래프트 _ Node.js (0) | 2022.11.19 |
[백준] 2805번 나무 자르기 _ Node.js (0) | 2022.11.15 |
[백준] 1261번 알고스팟_Node.js (0) | 2022.11.14 |
[백준] 14225번 부분수열의 합 _ Node.js (0) | 2022.11.13 |