Submission
Status:
[PP-SS][SSSSS][SSSSSSSSSS]
Subtask/Task Score:
{0/20}{0/30}{0/50}
Score: 0
User: C12
Problemset: ห้องสมุดเมือง 3M
Language: cpp
Time: 0.002 second
Submitted On: 2026-01-16 22:46:46
#include <bits/stdc++.h>
using namespace std;
const int N = 2e7+10;
int sweep[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int total = 0, mx = 0, mn =1e9;
for(int i = 0, x, y; i < n; ++i){
cin >> x >> y;
total += y-x;
mx = max(mx, y-1);
mn = min(mn, x);
sweep[x]++;
sweep[y]--;
}
int sum = 0, cnt = 0;
for(int i = 0; i <= 20 * 1000 * 1000; ++i){
sum += sweep[i];
cnt += sum;
if(cnt >= total/2){
cout << i << '\n';
return 0;
}
}
}