Submission #202869

# Submission time Handle Problem Language Result Execution time Memory
202869 2020-02-18T12:41:02 Z mraron Just Long Neckties (JOI20_ho_t1) C++14
Compilation error
0 ms 0 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(b.begin(),b.end());	
	//~ for(int i=0;i<n+1;++i) {
		//~ vector<int> lst;
		//~ for(int j=0;j<n+1;++j) if(i!=j) lst.push_back(a[j].xx);
		//~ sort(lst.begin(),lst.end());
		//~ int mx=0;
		//~ for(int j=0;j<n;++j) mx=max(mx, max(0, lst[j]-b[j].xx));
		//~ cout<<mx<<" \n"[i==n];
	//~ }
	
	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]<<" \n"[i==n];
	
	return 0;
}
6

Compilation message

ho_t1.cpp:63:1: error: expected unqualified-id before numeric constant
 6
 ^