Submission #959793

# Submission time Handle Problem Language Result Execution time Memory
959793 2024-04-09T06:04:33 Z happy_node Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
using namespace std;

const int MX=2e5+5;

int N;
int A[MX], B[MX], pf[MX], sf[MX];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);

	cin>>N;
	for(int i=1;i<=N+1;i++) cin>>A[i];
	for(int i=1;i<=N;i++) cin>>B[i];
	vector<int> ordA,ordB;
	for(int i=1;i<=N+1;i++) ordA.push_back(i);
	for(int i=1;i<=N;i++) ordB.push_back(i);
	sort(ordA.begin(),ordA.end(),[&](int i, int j){
		return A[i]<A[j];
	});
	sort(ordB.begin(),ordB.end(),[&](int i, int j){
		return B[i]<B[j];
	});

	for(int i=1;i<=N;i++) {
		int x=ordA[i-1],y=ordB[i-1];
		pf[i]=max(pf[i-1],max(0,A[x]-B[y]));
	}
	for(int i=N+1;i>1;i--) {
		int x=ordA[i-1],y=ordB[i-2];
		sf[i]=max(sf[i+1],max(0,A[x]-B[y]));
	}

	for(int i=1;i<=N+1;i++) {
		cout<<max(pf[i-1],sf[i+1])<<" ";
	}
	cout<<'\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -