제출 #763483

#제출 시각아이디문제언어결과실행 시간메모리
763483vjudge1Just Long Neckties (JOI20_ho_t1)C++17
9 / 100
77 ms11176 KiB
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, maxx = 0, dp[200001], save[200001];
	pair<int, int> pa[200001];
	cin >> n;
	for(int i = 1; i <= n + 1; i++)
	{
		cin >> pa[i].first;
		pa[i].second = i;
	}
	for(int i = 1; i <= n; i++)
	{
		cin >> dp[i];
	}
	sort(dp + 1, dp + n + 1);
	sort(pa + 1, pa + n + 2);
	for(int i = 1; i <= n; i++)
	{
		maxx = max(maxx, max(pa[i].first - dp[i], 0));
	}
	save[pa[n + 1].second] = maxx;
	for(int i = n; i >= 1; i--)
	{
		maxx = max(maxx, max(pa[i + 1].first - dp[i], 0));
		save[pa[i].second] = maxx;
	}
	for(int i = 1; i <= n + 1; i++)	
	{
		cout << save[i] << " ";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...