Submission #216811

# Submission time Handle Problem Language Result Execution time Memory
216811 2020-03-28T06:03:19 Z oolimry Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>

using namespace std;
typedef pair<long long, long long> ii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	ii A[n+1]; long long B[n];
	long long ans[n+1];
	for(int i = 0;i <= n;i++){
		cin >> A[i].first; A[i].second = i;
	}
	for(int i = 0;i < n;i++) cin >> B[i];
	
	sort(A, A + (n+1));
	sort(B, B + (n));
	
	long long pre[n];
	long long suf[n];
	
	for(int i = 0;i < n;i++){
		pre[i] = max(A[i].first - B[i], 0LL);
		if(i != 0) pre[i] = max(pre[i-1],pre[i]);
	}
	
	for(int i = 0;i < n;i++){
		suf[i] = max(A[n-i].first - B[n-i-1], 0LL);
		if(i != 0) suf[i] = max(suf[i-1],suf[i]);
	}
	
	for(int i = 0;i < n;i++){
		cout << pre[i] << " " << suf[i] << "\n";
	}
	
	for(int i = 0;i <= n;i++){
		long long res = 0;
		if(i != n) res = max(res, suf[n-i-1]);
		if(i != 0) res = max(res, pre[i-1]);
		ans[A[i].second] = res;
	}
	
	for(int i = 0;i <= n;i++) cout << ans[i] << " ";
	
}

/*
3
4 3 7 6
2 6 4
*/


# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -