백준 25305 커트라인 / C++

이유참치·2025년 12월 15일

백준

목록 보기
191/248

문제 : 25305

풀이 point

정렬을 하면 N-K의 인덱스가 커트라인이 된다.

코드

//백준 25305, 커트라인
#include <iostream>
#include <algorithm>

int main(){
    int N, k;
    int student[10000];
    std::cin >> N >> k;

    for(int i{0}; i<N; ++i){
        std::cin >> student[i];
    }

    std::sort(student, student+N);

    std::cout << student[N-k];

    return 0;
}
profile
임아리 - 대학생

0개의 댓글