Untitled
unknown
plain_text
2 years ago
832 B
7
Indexable
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;cin>>n;
vector<int>start(n);
vector<int>end(n);
for(int i=0;i<n;i++) {
cin>>start[i];
}
for(int i=0;i<n;i++) {
cin>>end[i];
end[i]++;
}
sort(start.begin(),start.end());
sort(end.begin(),end.end());
int i = 1,j = 0;
int maxHeight = 0;
int height = 0;
int ans = 0;
while(i<n && j<n) {
if(start[i]<end[j]) {
height++;
if(maxHeight<height) {
maxHeight = height;
ans = start[i];
}
i++;
} else {
height--;
j++;
}
}
cout<<ans<<endl;
return 0;
}
/*
*/
Editor is loading...