Problem Solving/백준
[백준/C++] 2693번 N번째 큰 수
높은곳에영광
2022. 2. 10. 14:22
#include <iostream>
#include <iomanip>
#include <vector>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
int N;
vector<int> arr(10);
cin >> N;
for(int i = 0; i < N; i++) {
for(int j = 0; j < 10; j++) {
cin >> arr[j];
}
sort(arr.begin(), arr.end(), greater<>());
cout << arr[2] << "\n";
}
}
매 배열을 받을 때 마다 algorithm header에 있는 sort function을 이용하였습니다.
사용할 때 functional header에 있는 greater를 사용해서 내림차순으로 정렬하였습니다.
헤더파일을 알고 있으면 매우 간단하게 정리되는 문제였습니다.
문제: https://www.acmicpc.net/problem/2693
2693번: N번째 큰 수
첫째 줄에 테스트 케이스의 개수 T(1 ≤ T ≤ 1,000)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 배열 A의 원소 10개가 공백으로 구분되어 주어진다. 이 원소는 1보다 크거나 같고, 1,000
www.acmicpc.net