# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
626456 | Abrar_Al_Samit | Just Long Neckties (JOI20_ho_t1) | C++17 | 1087 ms | 4760 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;
void PlayGround() {
int n;
cin>>n;
vector<pair<int,int>>a(n+1);
for(int i=0; i<n+1; i++) {
cin>>a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end());
int b[n];
for(int i=0; i<n; ++i) {
cin>>b[i];
}
sort(b, b+n);
int ans[n+1] = {0};
int pre[n+1] = {0}, suf[n+1] = {0};
for(int i=0; i<n; ++i) {
int strangeness = max(0, a[i+1].first-b[i]);
for(int j=0; j<=i; ++j) {
ans[a[j].second] = max(ans[a[j].second], strangeness);
}
strangeness = max(0, a[i].first-b[i]);
for(int j=i+1; j<n+1; ++j) {
ans[a[j].second] = max(ans[a[j].second], strangeness);
}
}
for(int i=0; i<n+1; ++i) {
cout<<ans[i]<<' ';
}
cout<<'\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
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... |