Submission #1158497

#TimeUsernameProblemLanguageResultExecution timeMemory
1158497crispxxJust Long Neckties (JOI20_ho_t1)C++20
9 / 100
1095 ms10820 KiB
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n; cin >> n;
	
	vector<int> a(n + 1), b(n);
	
	for(auto &x : a) cin >> x;
	for(auto &x : b) cin >> x;
	
	sort(b.begin(), b.end());
	
	for(int i = 0; i < n + 1; i++) {
		map<int, int> mp;
		
		for(int j = 0; j < n + 1; j++) {
			if(i == j) continue;
			mp[a[j]]++;
		}
		
		int res = 0;
		
		for(int j = 0; j < n; j++) {
			auto it = mp.begin();
			int v = it -> first;
			res = max(res, max(0, v - b[j]));
			if(--mp[v] == 0) mp.erase(v);
		}
		
		cout << res << ' ';
	}
	
	cout << nl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...