Deep_Dev

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV139KOaABgCFAYh&categoryId=AV139KOaABgCFAYh&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=5 

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

 


๋ฌธ์ œ์„ค๋ช…์€ ๊ธด๋ฐ ๊ทธ๋ƒฅ ์ •๋ ฌ ๋ฌธ์ œ์ด๋‹ค.

100๊ฐœ๋ฅผ ๋‹ด์€ ๋ฐฐ์—ด์„, ํ‰ํƒ„ํ™”ํ•  ํšŸ์ˆ˜๋งŒํผ [์ •๋ ฌ] - ์ตœ๋Œ€๊ฐ’์€ -1 - ์ตœ์†Œ๊ฐ’์€ +1 ๋ฐ˜๋ณตํ•ด์ฃผ๊ณ 

ํ‰ํƒ„ํ™”๊ฐ€ ๋๋‚˜๊ณ  ์ตœ๋Œ€๊ฐ’ - ์ตœ์†Œ๊ฐ’์ด ์ •๋‹ต

 

 

 

import java.util.Scanner;
import java.util.Arrays;
class Solution{
    public static void main(String args[]) throws Exception{
        Scanner kb = new Scanner(System.in);
        int t = 10;
        for (int test_case = 1; test_case <= t; test_case++) {
            int n = kb.nextInt(); // ๋คํ”„ ํšŸ์ˆ˜
            int[] arr=new int[100];
            for(int i=0; i<100; i++){
                arr[i]=kb.nextInt();
            }
            int max=0;
            int min=0;
            for(int i=0; i<n; i++){
                Arrays.sort(arr);
                max=arr[99]--;
                min=arr[0]++;
            }
            Arrays.sort(arr);
            max=arr[99];
            min=arr[0];
            System.out.println("#"+test_case+" "+(max-min));

        }
    }
}