# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224010 | dwsc | Just Long Neckties (JOI20_ho_t1) | C++14 | 4 ms | 256 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 int long long
using namespace std;
main(){
int n;
cin >> n;
int arr[n+1];
for (int i = 0; i < n+1; i++) cin >> arr[i];
int arr2[n];
for (int i = 0; i < n; i++) cin >> arr2[i];
sort(arr,arr+n+1);
sort(arr2,arr2+n);
int ans[n+1];
ans[n] = 0;
multiset<int> s;
for (int i = 0; i < n; i++) s.insert(max(arr[i]-arr2[i],0LL));
ans[n] = *(--s.end());
for (int i = n-1; i >= 0; i--){
s.erase(s.find(max(arr[i]-arr2[i],0LL)));
s.insert(max(arr[i+1]-arr2[i],0LL));
ans[i] = *(--s.end());
}
for (int i = 0; i < n+1; 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... |