Submission #509596

# Submission time Handle Problem Language Result Execution time Memory
509596 2022-01-14T07:12:53 Z CSQ31 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
int a[200001],b[200001],s[200001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n+1;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	sort(b,b+n);
	sort(a,a+n+1);
	for(int i=n;i>0;i--){
		s[i] = max(0,a[i] - b[i-1]);
		if(i!=n)s[i] = max(s[i],s[i+1]);
	}
	int cur = 0;
	for(int i=0;i<=n;i++){
		int ans = cur;
		if(i!=n){
			ans = max(ans,s[i+1]);
			cur=max(cur,a[i]-b[i]);
		}
		cout<<ans;
		if(i!=n)cout<<" ";
	}
	cout<<'\n';
	
	
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -