# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121274 | Hduong | Just Long Neckties (JOI20_ho_t1) | C++17 | 1051 ms | 10068 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 task "task"
using namespace std;
const int N = 2e5 + 5;
long long a[N], n, b[N];
pair <long long, long long> pi[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n + 1; i++) {
cin >> a[i];
pi[i].first = a[i];
pi[i].second = i;
}
for (int i = 1; i <= n; i++) cin >> b[i];
sort(b + 1, b + n + 1);
sort(pi + 1, pi + n + 2);
for (int i = 1; i <= n + 1; i++) {
long long res = 0, id = 1;
for (int j = 1; j <= n + 1; j++) {
if (pi[j].second == i) continue ;
// cout << pi[j].second << " ";
res = max(res, max(pi[j].first - b[id++], 0ll));
}
// cout << "\n";
cout << res << " ";
}
}
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... |