본문 바로가기
백준(C++)/정렬

[BOJ/C++]25305번_커트라인

by 코잼민 2024. 7. 10.

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

 

##문제 풀기 전 내가 알고 있었어야 할 개념: 없음

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int compare(const void* a, const void* b) {
    return (*(int*)b - *(int*)a);
}
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int N,K;
    int* scores;
    cin >> N >> K;
 
    scores = new int[N];
 
    for (int i = 0; i < N; i++) {
        cin >> scores[i];
    }
 
    qsort(scores, N, sizeof(int), compare);
 
    cout << scores[K - 1<< '\n';
 
    delete[] scores;
 
    return 0;
}
cs

'백준(C++) > 정렬' 카테고리의 다른 글

[BOJ/C++]11651번_좌표 정렬하기2  (0) 2024.07.10
[BOJ/C++]10989번_수정렬하기3  (0) 2024.07.10
[BOJ/C++]2587번_대표값2  (0) 2024.07.08
[BOJ/C++]2750번_수정렬하기  (0) 2024.07.07
[BOJ/C++]1427번_소트인사이드  (0) 2024.07.07