그냥 우선순위 큐에 다 넣고 하나씩 pop해서 제출하면 메모리 초과가 난다.
어차피 찾는 수가 고정되어 있고 nxn 배열에서 두번째 행은 첫번째 행보다 무조건 크기 때문에 n개씩 우선순위 큐에 삽입하고 행끼리 계속해서 비교해주면 된다.
#include <bits/stdc++.h>
using namespace std;
int n, sum;
priority_queue<int,vector<int>,greater<int>> q;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int x;
cin >> x;
if (q.size() != n) {
q.push(x);
}
else {
if (x > q.top()) {
q.pop();
q.push(x);
}
}
}
}
cout << q.top() << '\n';
}