Submission #202864

# Submission time Handle Problem Language Result Execution time Memory
202864 2020-02-18T11:35:20 Z mraron Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
5 ms 376 KB
#include<bits/stdc++.h>
using namespace std;

#define xx first
#define yy second
//3 4 6 7
//2 4 6
//3 4 7
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<pair<int,int>> a(n+1), b(n);
	for(int i=0;i<n+1;++i) {
		cin>>a[i].xx;
		a[i].yy=i;
	}
	for(int i=0;i<n;++i) {
		cin>>b[i].xx;
		b[i].yy=i;
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	vector<int> pre(n+1);
	vector<int> suf(n+1);
	for(int i=0;i<n;++i) {
		pre[i]=max(0, a[i+1].xx-b[i].xx);
		suf[i+1]=max(0, a[i].xx-b[i].xx);
	}
	
	for(int i=n-1;i>=0;i--) pre[i]=max(pre[i], pre[i+1]);
	for(int i=1;i<n+1;i++) suf[i]=max(suf[i], suf[i-1]);
	
	//~ for(auto i:pre) {
		//~ cerr<<i<<" ";
	//~ }cerr<<"\n";
	
	
	//~ for(auto i:suf) {
		//~ cerr<<i<<" ";
	//~ }cerr<<"\n";
	
	vector<int> ans=pre;
	for(int i=n;i>=0;i--) ans[i]=max(ans[i], suf[i]);
	
	for(int i=0;i<n+1;++i) cout<<ans[a[i].yy]<<" ";
	cout<<"\n";
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -