# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1151045 | nguyn | Just Long Neckties (JOI20_ho_t1) | C++20 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>
const int N = 2e5 + 5;
int n;
int a[N], b[N];
int pre[N], suf[N];
signed main(){
ios_base::sync_with_stdio(false) ;
cin.tie(0) ; cout.tie(0) ;
if (fopen("INP.INP" ,"r")) {
freopen("INP.INP" ,"r" , stdin) ;
freopen("OUT.OUT" , "w" , stdout) ;
}
cin >> n;
for (int i = 1; i <= n + 1; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
sort(a + 1, a + 2 + n);
sort(b + 1, b + 1 + n);
for (int i = 1; i <= n; i++) {
pre[i] = max(pre[i - 1], a[i] - b[i]);
}
for (int i = n; i >= 1; i--) {
suf[i] = max(suf[i + 1], a[i + 1] - b[i]);
}
for (int i = 1; i <= n + 1; i++) {
cout << max(pre[i - 1], suf[i]) << ' ';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |