Submission
Status:
[PPPPP][PPPPP][TSSSSSSSSS]
Score: 50
User: Nightingale
Problemset: ห้องสมุดเมือง 3M
Language: cpp
Time: 1.115 second
Submitted On: 2025-03-31 19:13:58
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a;
cin >> a;
multiset<int> book;
for(int i=0; i<a; i++) {
int b, c;
cin >> b >> c;
if(b > c) swap(b, c);
for(int j = b; j < c; j++) {
book.insert(j);
}
}
auto it = book.begin();
advance(it, book.size()/2 - (book.size() > 0 ? 1 : 0)); // Get the median-like element
cout << *it << "\n";
}