# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224020 | cheeheng | Just Long Neckties (JOI20_ho_t1) | C++14 | 315 ms | 14840 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>
using namespace std;
typedef pair<int, int> ii;
ii C[200005];
int B[200005];
int ans[200005];
// 3 4 6 7
// 2 4 6
int main(){
int N;
scanf("%d", &N);
for(int i = 0; i <= N; i ++){
int x;
scanf("%d", &x);
C[i] = ii(x, i);
}
sort(C, C+(N+1));
for(int i = 0; i < N; i ++){
scanf("%d", &B[i]);
}
sort(B, B+N);
multiset<int> oddities;
for(int i = 0; i < N; i ++){
oddities.insert(max(C[i].first-B[i], 0));
}
ans[C[N].second] = *(--oddities.end());
for(int i = N-1; i >= 0; i --){
oddities.erase(max(C[i].first-B[i], 0));
oddities.insert(max(C[i+1].first-B[i], 0));
ans[C[i].second] = *(--oddities.end());
}
for(int i = 0; i <= N; i ++){
printf("%d ", ans[i]);
}
return 0;
}
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... |