# Link

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

 

2075번: N번째 큰 수

첫째 줄에 N(1 ≤ N ≤ 1,500)이 주어진다. 다음 N개의 줄에는 각 줄마다 N개의 수가 주어진다. 표에 적힌 수는 -10억보다 크거나 같고, 10억보다 작거나 같은 정수이다.

www.acmicpc.net

 

 

# Code - C++

//
//  BOJ
//  ver.C++
//
//  Created by GGlifer
//
//  Open Source

#include <iostream>
#include <queue>

using namespace std;

#define endl '\n'
#define len(x) (int)(x).length()
#define size(x) (int)(x).size()
#define str(x) to_string(x)
#define error logic_error("line " + str(__LINE__))

// Set up : Definitions
/* None */

// Set up : Global Variables
/* None */

// Set up : Functions Declaration
/* None */


int main()
{
    // Set up : I/O
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Set up : Input
    int N; cin >> N;
    priority_queue<int,vector<int>,greater<>> pq;
    for (int i=0; i<N; i++) {
        int num; cin >> num;
        pq.push(num);
    }

    for (int i=0; i<N-1; i++) {
        for (int j=0; j<N; j++) {
            int num; cin >> num;

            // Process
            if (num > pq.top()) {
                pq.pop();
                pq.push(num);
            }
        }
    }

    // Control : Output
    cout << pq.top() << endl;
}

// Helper Functions
/* None */

 

 

지적, 조언, 첨언 모두 환영합니다!!!

+ Recent posts