제출 #701677

#제출 시각아이디문제언어결과실행 시간메모리
701677vjudge1Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
91 ms12308 KiB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long
#define inf ((int)1e18)
#define N 200005
using namespace std;
int brr[N], ans[N];
vector <pair<int, int> > arr;

int32_t main(){
	fast
	int n;
	cin>>n;
	arr.resize(n+2);
	for(int i=1; i <= n+1; i++){
		cin>>arr[i].first;
		arr[i].second=i;
	}
	for(int i=1; i <= n; i++){
		cin>>brr[i];
	}
	sort(arr.begin(), arr.end());
	sort(brr, brr+n+1);
	int tans=0;
	for(int i=1; i <= n; i++){
		tans=max(tans, max(0ll, arr[i].first-brr[i]));
	}
	ans[arr[n+1].second]=tans;
	for(int i=n; i >= 1; i--){
		int index = arr[i].second;
		tans=max(tans, max(0ll, arr[i+1].first-brr[i]));
		ans[index]=tans;
	}
	for(int i=1; i <= n+1; i++){
		cout<<ans[i]<<" ";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...