Submission #765635

# Submission time Handle Problem Language Result Execution time Memory
765635 2023-06-25T00:26:40 Z NK_ Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 212 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

template<class T> using V = vector<T>;

const int INF = int(1e9) + 10;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; cin >> N;
	V<int> A(N + 1); for(auto& x : A) cin >> x;
	V<int> B(N); for(auto& x : B) cin >> x;

	sort(begin(A), end(A));
	sort(begin(B), end(B));


	V<int> P(N + 1, 0);
	for(int i = 0; i < N; i++) P[i] = max(A[i] - B[i], (i-1 >= 0 ? P[i-1] : 0));
	
	V<int> S(N + 1, 0);
	for(int i = N; i >= 1; i--) S[i] = max(A[i] - B[i-1], (i+1 <= N ? S[i+1] : 0));
	
	// for(auto x : P) cout << x << " ";
	// cout << nl;
	
	// for(auto x : S) cout << x << " ";
	// cout << nl;
	

	for(int i = 0; i <= N; i++) {
		int ans = 0;
		if (i-1 >= 0) ans = max(ans, P[i - 1]);
		if (i+1 <= N) ans = max(ans, S[i + 1]);
		cout << ans << " ";
	}
	cout << nl;


    return 0;
}


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