728x90
🤖
문제
https://www.acmicpc.net/problem/10818
풀이
const fs = require("fs");
const input = fs.readFileSync("/dev/stdin").toString().split("\n");
const N = +input[0];
const inputArr = input[1].split(" ");
let min = +inputArr[0];
let max = +inputArr[0];
for (let i = 1; i < N; i++) {
min = min < +inputArr[i] ? min : +inputArr[i];
max = max > +inputArr[i] ? max : +inputArr[i];
}
console.log(min, max);
1. (line 4, 7, 8, 11, 12) 데이터를 넘버 타입으로 변환하기 위해 + 단항 연산자를 활용하였습니다.
728x90
'유물 > └ 백준' 카테고리의 다른 글
<백준> 2577번: 숫자의 개수 (0) | 2022.01.06 |
---|---|
<백준> 2562번: 최댓값 (0) | 2022.01.05 |
<백준> 1110번: 더하기 사이클 (0) | 2022.01.04 |
<백준> 10951번: A+B - 4 (0) | 2022.01.04 |
<백준> 10952번: A+B - 5 (0) | 2022.01.04 |