# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203108 | 2020-02-19T12:09:35 Z | ZwariowanyMarcin | Just Long Neckties (JOI20_ho_t1) | C++14 | 5 ms | 376 KB |
#include <bits/stdc++.h> #define LL long long #define pb push_back #define mp make_pair #define ss(x) (int) x.size() #define fi first #define se second #define cat(x) cerr << #x << " = " << x << endl #define rep(i, j, n) for (int i = j; i <= n; ++i) #define per(i, j, n) for (int i = n; j <= i; --i) using namespace std; const int nax = 2e5 + 111; int n; pair<int,int> a[nax]; int b[nax]; int s[nax][2]; int ans[nax]; int main() { scanf ("%d", &n); rep(i, 1, n + 1) { scanf ("%d", &a[i].fi); a[i].se = i; } rep(i, 1, n) scanf ("%d", b + i); sort(b + 1, b + n + 1); sort(a + 1, a + n + 2); rep(i, 1, n) { s[i][0] = abs(b[i] - a[i].fi); s[i][1] = abs(b[i] - a[i + 1].fi); } rep(i, 1, n) s[i][0] = max(s[i][0], s[i - 1][0]); per(i, 1, n) s[i][1] = max(s[i][1], s[i + 1][1]); rep(i, 1, n + 1) { // printf ("%d %d %d\n", i, s[i - 1][0], s[i][1]); int x = (i > 0 ? s[i - 1][0] : 0); x = max(x, s[i][1]); ans[a[i].se] = x; } rep(i, 1, n + 1) printf ("%d ", ans[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |