# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094364 | imarn | Just Long Neckties (JOI20_ho_t1) | C++14 | 75 ms | 10836 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>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
using namespace std;
const int mxn=2e5+5;
int t[2*mxn]{0};
void upd(int i,int amt,int sz){
i+=sz;t[i]=amt;
for(i>>=1;i;i>>=1)t[i]=max(t[2*i],t[2*i+1]);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;pii a[n+1];int b[n];
for(int i=0;i<n+1;i++)cin>>a[i].f,a[i].s=i;
for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n);
for(int i=0;i<n;i++)t[i+n]=a[i+1].f-b[i];
for(int i=n-1;i>0;i--)t[i]=max(t[2*i],t[2*i+1]);
int rs[n+1]={0};
for(int i=0;i<n+1;i++){
rs[a[i].s] = max(t[1],0);upd(i,a[i].f-b[i],n);
}for(int i=0;i<n+1;i++)cout<<rs[i]<<' ';
}
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... |