๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/Algorithm

[๋ฐฑ์ค€][Node.js] 9076๋ฒˆ : ์ ์ˆ˜ ์ง‘๊ณ„

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 12. 17.

 

 

Algorithm

-  ์ ์ˆ˜ ์ง‘๊ณ„ -

 


 

๋ฌธ์ œ

ํ•œ๊ตญ ์ฒด์กฐํ˜‘ํšŒ์—์„œ๋Š” ์‹ฌํŒ์˜ ์˜ค์‹ฌ์„ ๋ง‰๊ธฐ ์œ„ํ•˜์—ฌ ์ ์ˆ˜ ์ง‘๊ณ„ ์‹œ์Šคํ…œ์„ ๊ณ ์น˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค.

์ด์ „์—๋Š” 5๋ช…์˜ ์‹ฌํŒ์ด 1์ ๋ถ€ํ„ฐ 10์ ๊นŒ์ง€ ์ •์ˆ˜์˜ ์ ์ˆ˜๋ฅผ ์ฃผ๋ฉด ์ตœ๊ณ ์ ๊ณผ ์ตœ์ €์ ์„ ํ•˜๋‚˜์”ฉ ์ œ์™ธํ•œ ์ ์ˆ˜์˜ ํ•ฉ์„ ์ด์ ์œผ๋กœ ํ•˜์˜€๋‹ค.

์ด๋ฅผ ๋ณด์™„ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ตœ๊ณ ์ ๊ณผ ์ตœ์ €์ ์„ ๋บ€ ๋‚˜๋จธ์ง€ 3๋ช… ์ ์ˆ˜์˜ ์ตœ๊ณ ์ ๊ณผ ์ตœ์ €์ ์˜ ์ฐจ์ด๊ฐ€ 4์  ์ด์ƒ ๋‚˜๊ฒŒ ๋˜๋ฉด ์ ์ˆ˜ ์กฐ์ •์„ ๊ฑฐ์ณ์„œ ๋‹ค์‹œ ์ ์ˆ˜๋ฅผ ๋งค๊ธฐ๋ ค๊ณ  ํ•œ๋‹ค.

์ ์ˆ˜๋ฅผ ์ง‘๊ณ„ํ•˜์—ฌ ์ด์ ์„ ๊ณ„์‚ฐํ•˜๊ฑฐ๋‚˜, ์ ์ˆ˜ ์กฐ์ •์„ ๊ฑฐ์ณ์„œ ๋‹ค์‹œ ์ ์ˆ˜๋ฅผ ๋งค๊ธฐ๋ ค๊ณ  ํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ์ด์  ๋Œ€์‹  KIN(Keep In Negotiation)์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

 

๋ฌธ์ œ ํ’€๊ธฐ

const readline = require("readline");
const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});
let input = [];
rl.on("line", function (line) {
	input.push(line.toString());
}).on("close", function () {
	input.shift();
	input = input.map((el) => el.split(" ").map((el) => Number(el)));

	for (let i = 0; i < input.length; i++) {
		let grade = input[i].sort((a, b) => a - b);
		if (grade[grade.length - 2] - grade[1] >= 4) {
			console.log("KIN");
		} else {
			console.log(grade.slice(1, -1).reduce((past, curr) => past + curr, 0));
		}
	}
	process.exit();
});

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€