Submission
Status:
[PPPPP][PPPPP][xSSSSSSSSS]
Subtask/Task Score:
{20/20}{30/30}{0/50}
Score: 50
User: Ryuthin94
Problemset: ห้องสมุดเมือง 3M
Language: cpp
Time: 0.304 second
Submitted On: 2026-03-05 23:01:55
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
if (!(cin >> n))
{
return 0;
}
vector<int> books;
for (int i = 0; i < n; i++)
{
long long tx, ty;
cin >> tx >> ty;
for (long long j = tx; j < ty; j++)
{
books.push_back(j);
}
}
if (books.empty())
{
return 0;
}
sort(books.begin(), books.end());
long long pos = books.size() / 2 - 1;
if (pos <= 0)
{
cout << books[0];
return 0;
}
cout << books[pos];
}