๐Ÿ“ฆ Chango/๐Ÿฃ EDOC

[BOJ B2][C++] ๋ฐฑ์ค€ 9076๋ฒˆ : ์ ์ˆ˜ ์ง‘๊ณ„

์„ ๋‹ฌ 2022. 3. 23. 03:51
๋ฐ˜์‘ํ˜•

https://www.acmicpc.net/problem/9076

 

9076๋ฒˆ: ์ ์ˆ˜ ์ง‘๊ณ„

์ž…๋ ฅ์˜ ์ฒซ ์ค„์—๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T(1 ≤ T ≤ 10)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ•œ ์ค„์— ๋‹ค์„ฏ ์‹ฌํŒ์ด ์ค€ ์ ์ˆ˜ ๋‹ค์„ฏ ๊ฐœ์˜ ์ •์ˆ˜ Ni(1 ≤ Ni ≤ 10, i = 1, 2, ..., 5)๊ฐ€ ํ•˜๋‚˜์˜ ๊ณต๋ฐฑ์„ ์‚ฌ์ด์— ๋‘๊ณ 

www.acmicpc.net

 

๋ฌธ์ œ

ํ•œ๊ตญ ์ฒด์กฐํ˜‘ํšŒ์—์„œ๋Š” ์‹ฌํŒ์˜ ์˜ค์‹ฌ์„ ๋ง‰๊ธฐ ์œ„ํ•˜์—ฌ ์ ์ˆ˜ ์ง‘๊ณ„ ์‹œ์Šคํ…œ์„ ๊ณ ์น˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค. ์ด์ „์—๋Š” 5๋ช…์˜ ์‹ฌํŒ์ด 1์ ๋ถ€ํ„ฐ 10์ ๊นŒ์ง€ ์ •์ˆ˜์˜ ์ ์ˆ˜๋ฅผ ์ฃผ๋ฉด ์ตœ๊ณ ์ ๊ณผ ์ตœ์ €์ ์„ ํ•˜๋‚˜์”ฉ ์ œ์™ธํ•œ ์ ์ˆ˜์˜ ํ•ฉ์„ ์ด์ ์œผ๋กœ ํ•˜์˜€๋‹ค. ์ด๋ฅผ ๋ณด์™„ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ตœ๊ณ ์ ๊ณผ ์ตœ์ €์ ์„ ๋บ€ ๋‚˜๋จธ์ง€ 3๋ช… ์ ์ˆ˜์˜ ์ตœ๊ณ ์ ๊ณผ ์ตœ์ €์ ์˜ ์ฐจ์ด๊ฐ€ 4์  ์ด์ƒ ๋‚˜๊ฒŒ ๋˜๋ฉด ์ ์ˆ˜ ์กฐ์ •์„ ๊ฑฐ์ณ์„œ ๋‹ค์‹œ ์ ์ˆ˜๋ฅผ ๋งค๊ธฐ๋ ค๊ณ  ํ•œ๋‹ค. ์ ์ˆ˜๋ฅผ ์ง‘๊ณ„ํ•˜์—ฌ ์ด์ ์„ ๊ณ„์‚ฐํ•˜๊ฑฐ๋‚˜, ์ ์ˆ˜ ์กฐ์ •์„ ๊ฑฐ์ณ์„œ ๋‹ค์‹œ ์ ์ˆ˜๋ฅผ ๋งค๊ธฐ๋ ค๊ณ  ํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ์ด์  ๋Œ€์‹  KIN(Keep In Negotiation)์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ

์ž…๋ ฅ์˜ ์ฒซ ์ค„์—๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T(1 ≤ T ≤ 10)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ•œ ์ค„์— ๋‹ค์„ฏ ์‹ฌํŒ์ด ์ค€ ์ ์ˆ˜ ๋‹ค์„ฏ ๊ฐœ์˜ ์ •์ˆ˜ Ni(1 ≤ Ni ≤ 10, i = 1, 2, ..., 5)๊ฐ€ ํ•˜๋‚˜์˜ ๊ณต๋ฐฑ์„ ์‚ฌ์ด์— ๋‘๊ณ  ์ฃผ์–ด์ง„๋‹ค.

์ถœ๋ ฅ

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์— ๋Œ€ํ•ด์„œ ์ด์ ์„ ํ•œ ์ค„์”ฉ ์ถœ๋ ฅํ•œ๋‹ค. ๋งŒ์ผ ์ ์ˆ˜ ์กฐ์ •์„ ๊ฑฐ์ณ์„œ ๋‹ค์‹œ ์ ์ˆ˜๋ฅผ ๋งค๊ธฐ๋ ค๊ณ  ํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ์ด์  ๋Œ€์‹  KIN์„ ์ถœ๋ ฅํ•œ๋‹ค.

 

ํ’€์ด

// Authored by : seondal
// ํ’€์ด : https://whkakrkr.tistory.com/
// Co-authored by : -

//#include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
        deque<int> d;
        
        for(int i=0; i<5; i++){
            int tmp;
            cin >> tmp;
            d.push_back(tmp);
        }
        
        sort(d.begin(), d.end());
        d.pop_back();
        d.pop_front();
        
        if(d.back() - d.front() >= 4) cout << "KIN\n";
        else cout << d[0] + d[1] + d[2] << "\n" ;
    }
    
    return 0;
}
    
/**/
๋ฐ˜์‘ํ˜•