제출 #548060

#제출 시각아이디문제언어결과실행 시간메모리
548060marlen7Just Long Neckties (JOI20_ho_t1)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define sz size()
#define push_ push_back
vector <int> a,b;
int sf[200005];
int pr[200005];
signed main(){
	int n,x;
	sf[0]=0;
	cin>>n;
	a.push_back(0);
	b.push_back(0);
	for (int i=1; i<=n+1; i++){
		cin>>x;
		a.push_back(x);
	}	
	for (int i=1; i<=n; i++){
		cin>>x;
		b.push_back(x);
	}
	sort (a.begin(),a.end());
	sort (b.begin(),b.end());
	sf[n+1]=0;
	for (int i=b.size()-1; i>0; i--){
		int h=(a[i+1]-b[i]);
		sf[i]=max(sf[i+1],max(0,h));
	}
	
	pr[0]=0;
	for (int i=1; i<=n; i++){
		pr[i]=max(pr[i-1],max(0,(a[i]-b[i])));
	}
	/*for (int i=1; i<=n; i++){
		cout<<pr[i]<<" ";
	}*/
	for (int i=0; i<=n; i++){
		cout<<max(pr[i-1],sf[i+1])<<" ";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...