Submission #1288846

#TimeUsernameProblemLanguageResultExecution timeMemory
1288846tunademayoJust Long Neckties (JOI20_ho_t1)C++20
9 / 100
1095 ms3700 KiB
#include<bits/stdc++.h>
using namespace std;

#define ll long long 

const bool Multitest = 0;

const int N = 2e5 + 10;

int n, a[N], b[N + 1];

int cal(int pos)
{
	vector<int> v;
	
	for(int i = 1 ; i <= n + 1 ; i++)
	{
		if(i != pos) v.push_back(a[i]);
	}
	
	sort(v.begin(), v.end());
	
	int ans = 0;
	
	for(int i = 0 ; i < n ; i++) ans = max(ans, max(v[i] - b[i + 1], 0));
	
	return ans;
}

void work()
{
	cin >> n;
	
	for(int i = 1 ; i <= n + 1 ; i++) cin >> a[i];
	for(int i = 1 ; i <= n ; i++) cin >> b[i];
	sort(b + 1, b + 1 + n);
	for(int i = 1 ; i <= n + 1 ; i++) cout << cal(i) << ' ';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);
	
	int q = 1;
	
	if(Multitest)	cin >> q;
	
	while(q--) work();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...