작성한 코드는 다음과 같다.
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
코드를 추가해 계산하는데 걸리는 시간을 줄여주는게 중요했다.
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
int arr[n*n];
for (int i=0; i<n*n; i++){
cin >> arr[i];
}
sort(arr, arr + n*n);
cout << arr[n*n - n] << endl;
return 0;
}
'백준' 카테고리의 다른 글
백준 20922 겹치는 건 싫어 c++ (0) | 2024.04.07 |
---|---|
백준 8979 올림픽 c++ (0) | 2024.04.06 |
백준 19637 IF문 좀 대신 써줘 c++ (0) | 2024.04.05 |
백준 1138 한 줄로 서기 c++ (0) | 2024.04.03 |
백준 1205 등수 구하기 c++ (0) | 2024.04.02 |