Submission
Status:
[-SSSS][SSSSS][SSSSSSSSSS]
Score: 0
User: punghy
Problemset: ห้องสมุดเมือง 3M
Language: cpp
Time: 0.002 second
Submitted On: 2025-03-19 11:23:08
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int range,total;
map<int,int> m;
cin>>range;
for (int i=0;i<range;i++) {
int temp_x,temp_y;
cin>>temp_x>>temp_y;
total+=temp_y-temp_x;
for (int j=temp_x;j<temp_y;j++) {
m[j]++;
}
}
int place;
if (total%2==1) {
place = (total-1)/2;
}else{
place = total/2;
}
//cout<<"["<<total<<" , "<<place<<"]";
for (auto i:m) {
place -= i.second;
//cout<<"[ "<<place<<" , "<<i.first<<" , "<<i.second<<" ]";
if (place<=0) {
cout<<i.first;
break;
}
}
return 0;
}