Submission #534385

# Submission time Handle Problem Language Result Execution time Memory
534385 2022-03-08T06:22:59 Z alvingogo Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

int main(){
	AquA;
	int n;
	cin >> n;
	vector<pair<int,int> > v(n+1);
	vector<int> b(n);
	for(int i=0;i<=n;i++){
		cin >> v[i].fs;
		v[i].sc=i;
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	sort(b.begin(),b.end());
	sort(v.begin(),v.end());
	vector<int> ans(n+1);
	multiset<int,greater<int> > m;
	for(int i=0;i<n;i++){
		m.insert(abs(v[i+1].fs-b[i]));
	}
	for(int i=0;i<=n;i++){
		ans[v[i].sc]=*m.begin();
		if(i!=n){
			m.erase(m.find(abs(v[i+1].fs-b[i])));
			m.insert(abs(v[i].fs-b[i]));
		}
	}
	for(int i=0;i<=n;i++){
		cout << ans[i] << " ";
	}
	cout << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -