답안 #534388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534388 2022-03-08T06:24:25 Z alvingogo Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 204 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
#define int long long
using namespace std;

signed 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -