Submission

Status:
[PPPPP][PPPPP][TSSSSSSSSS]

Score: 50

User: Nathlol2

Problemset: ห้องสมุดเมือง 3M

Language: cpp

Time: 1.074 second

Submitted On: 2025-03-15 22:22:15

#include <bits/stdc++.h>
using namespace std;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        for (int j = a;j < b;j++){
            mp[j]++;
        }
    }
    int c = 0;
    for(auto& p : mp){
        c += p.second;
    }

    int pos = c / 2;
    int cur = 0;
    for(auto p : mp){
        cur += p.second;
        if(cur > pos - 1){
            cout << p.first;
            return 0;
        }
    }
}