백준 25305

김경욱·2025년 8월 7일

백준

목록 보기
32/121

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);

    String line = in.nextLine();
    

    String[] word = line.split(" ");

    int people = Integer.parseInt(word[0]);

    int prize = Integer.parseInt(word[1]);

    int[] scores = new int[people];

    for (int i =0; i< people; i++)
    {
        scores[i] = in.nextInt();
    }

    Arrays.sort(scores);

    System.out.println(scores[people-prize]);













}

} 정렬을 배우니 정말 좋다 ^^

0개의 댓글