백준 [ALGORITHM] - 커트라인 (25305)
2024. 1. 28. 21:58ㆍ코딩/백준 [ALGORITHM]
반응형
#include <stdio.h>
#include <stdlib.h>
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}
int main() {
int count;
int n;
scanf("%d %d", &count, &n);
int* arr1 = (int*)malloc(count * sizeof(int));
for (int i = 0; i < count; i++) {
scanf("%d", &arr1[i]);
}
qsort(arr1, count, sizeof(int), compare);
if (n <= count) {
printf("%d", arr1[count - n]);
}
free(arr1);
return 0;
}
반응형
'코딩 > 백준 [ALGORITHM]' 카테고리의 다른 글
백준 [ALGORITHM] - 아이폰 9S (5883) (0) | 2024.02.02 |
---|---|
백준 [ALGORITHM] - 카드1 (2161) (0) | 2024.01.30 |
백준 [ALGORITHM] - 주사위 (1233) (0) | 2024.01.27 |
백준 [ALGORITHM] - 문서 검색 (1543) (0) | 2024.01.25 |
백준 [ALGORITHM] - 숫자 카드 (10815) (0) | 2024.01.24 |