Skip to content

Commit 4fbd5a1

Browse files
committed
boj(정렬): 23246_Sport Climbing Combined
1 parent 4262e76 commit 4fbd5a1

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const filePath = process.platform === 'linux' ? '/dev/stdin' : 'input.txt';
2+
const [a, ...b] = require('fs').readFileSync(filePath).toString().trim().split('\n');
3+
4+
const N = +a;
5+
const arr = b.map((_b) => _b.split(' ').map(Number));
6+
7+
arr.sort((a, b) => {
8+
if (a[1] * a[2] * a[3] === b[1] * b[2] * b[3]) {
9+
if (a[1] + a[2] + a[3] === b[1] + b[2] + b[3]) {
10+
return a[0] - b[0];
11+
}
12+
13+
return a[1] + a[2] + a[3] - (b[1] + b[2] + b[3]);
14+
}
15+
return a[1] * a[2] * a[3] - b[1] * b[2] * b[3];
16+
});
17+
console.log(arr[0][0], arr[1][0], arr[2][0]);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
N = int(input())
2+
infos = [tuple(map(int,input().split())) for _ in range(N)]
3+
infos = sorted(infos, key=lambda x: (x[1] * x[2] * x[3], x[1] + x[2] + x[3], x[0]))
4+
for b,p,q,r in infos[:3]:
5+
print(b, end=' ')

0 commit comments

Comments
 (0)