# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201407 | karma | Just Long Neckties (JOI20_ho_t1) | C++14 | 120 ms | 6192 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define fi first
#define se second
#define mp make_pair
//#define int int64_t
using namespace std;
const int N = int(2e5) + 5;
typedef pair<int, int> pii;
int ans[N], b[N], n, suf[N], cur;
pii a[N];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define Task "test"
if(fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> n; ++n;
for(int i = 1; i <= n; ++i) cin >> a[i].fi, a[i].se = i;
for(int i = 1; i < n; ++i) cin >> b[i];
sort(a + 1, a + n + 1); sort(b + 1, b + n);
for(int i = n, j = n - 1; i > 1; --i, --j) {
suf[i] = max(suf[i + 1], max(a[i].fi - b[j], 0));
}
cur = 0;
for(int i = 1; i <= n; ++i) {
ans[a[i].se] = max(cur, suf[i + 1]);
cur = max(cur, max(a[i].fi - b[i], 0));
}
for(int i = 1; i <= n; ++i) cout << ans[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... |