이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
vector<pair<bool,int>> pref[200005];
multiset<int> pos;
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
pair<int,int> niza[n+1];
for (int i = 0; i<n+1; i++) cin>>niza[i].first;
for (int i = 0; i<n+1; i++) niza[i].second = i;
int init[n];
for (int i = 0; i<n; i++) cin>>init[i];
sort(niza,niza+(n+1));
sort(init,init+n);
for (int i = 0; i<n; i++) {
int br = init[i];
int prv = niza[i].first;
int vtor = niza[i+1].first;
if (vtor-br > 0) {
pref[0].pb({1,vtor-br});
pref[i+1].pb({0,vtor-br});
}
if (prv-br > 0) {
pref[i+1].pb({1,prv-br});
pref[n+2].pb({0,prv-br});
}
}
for (int i = 0; i<n+1; i++) {
for (auto it:pref[i]) {
if (it.first == 0) pos.erase(pos.find(it.second));
else pos.insert(it.second);
}
auto orel = pos.end();
orel--;
cout<<*orel<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |