Submission #853395

# Submission time Handle Problem Language Result Execution time Memory
853395 2023-09-24T09:24:48 Z reginox Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 2504 KB
#include<bits/stdc++.h>
#define ll long long
#define sp << " "
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task " "
using namespace std;
ll n, a[200005], b[200005];

ll t1[200005], t2[200005];

void sub1(){
	ll c, ans;
	for(ll i = 1; i <= n+1; i++){
		c = 1, ans = -1e18;
		for(ll j = 1; j <= n; j++){
			if(c==i) c++;
			ans=max(ans, max(0ll, a[c]-b[j]));
			c++;
		}
		cout << ans << " ";
	}
}

void sub2(){
	for(ll i = 1; i <= n;i++){
		t1[i]=a[i+1]-b[i];
		t2[i]=a[i]-b[i];
	}
//	for(ll i = 1; i <= n; i++){
//		//cout << max(t1[i], t2[i-1]) sp;
//		cout << t1[i] sp << t2[i] << "\n";
//	}
	for(ll i = 1; i <= n; i++) t2[i]=max(t2[i], t2[i-1]);
	for(ll i = n; i >= 1; i--) t1[i]=max(t1[i], t1[i+1]);
	for(ll i = 1; i <= n+1; i++){
		cout << max(t1[i], t2[i-1]) sp;
		//cout << t1[i] sp << t2[i] << "\n";
	}
}
int main(){
	faster
	//freopen(task".inp","r",stdin);
	//freopen(task".out","w",stdout);
	cin >> n;
	for(ll i = 1; i <= n+1; i++) cin >> a[i];
	for(ll j = 1; j <= n; j++) cin >> b[j];
	sort(a+1,a+n+2);
	sort(b+1,b+n+1);
	if(n<=2000){
		sub1();
	}
	else{
		sub2();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -