# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226461 | thebes | Just Long Neckties (JOI20_ho_t1) | C++14 | 315 ms | 18680 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 2e5+5;
int N, i, b[MN], ans[MN];
pii a[MN];
multiset<int> dif;
int main(){
for(scanf("%d",&N),i=1;i<=N+1;i++){
scanf("%d",&a[i].first);
a[i].second=i;
}
for(i=1;i<=N;i++)
scanf("%d",&b[i]);
sort(b+1,b+N+1);
sort(a+1,a+N+2,[](pii i,pii j){return i.first<j.first;});
for(i=1;i<=N;i++)
dif.insert(a[i].first-b[i]);
for(i=N+1;i>=1;i--){
auto it=dif.end(); it--;
ans[a[i].second]=max(0,*it);
if(i!=1){
int ot = i-1;
dif.erase(dif.find(a[i-1].first-b[ot]));
dif.insert(a[i].first-b[ot]);
}
}
for(i=1;i<=N+1;i++)
printf("%d ",ans[i]);
printf("\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |