Submission #1114848

# Submission time Handle Problem Language Result Execution time Memory
1114848 2024-11-19T17:06:47 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 2384 KB
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 200007;

int n;

ll val1[MAXN];
ll val2[MAXN];

ll pref_max[MAXN];
ll suf_max[MAXN];

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for (int i = 1; n + 1 >= i; i++) {
		cin >> val1[i];
	}
	for (int i = 1; n >= i; i++) {
		cin >> val2[i];
	}
	sort(val1 + 1, val1 + n + 2);
	sort(val2 + 1, val2 + n + 1);
	ll p1;
	for (int i = 1; n >= i; i++) {
		p1 = max(pref_max[i - 1], ll(0));
		pref_max[i] = max(p1, val1[i] - val2[i]);
	}
	for (int i = n; i > 0; i--) {
		p1 = max(ll(0), suf_max[i + 1]);
		suf_max[i] = max(p1, val1[i + 1] - val2[i]);
	}
	
	for (int i = 1; n + 1 >= i; i++) {
		cout << max(pref_max[i - 1], suf_max[i]) << " ";
	}
	/*cout << "\n";
	for (int i = 1; n >= i; i++) {
		cout << pref_max[i] << " " << suf_max[i] << "\n";
	}*/
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -