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;
pair<int, int> a[200002];
int b[200002], diff1[200005], diff2[200005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
for(int i = 1; i <= n+1; i++){
cin>>a[i].first;
a[i].second = i;
}
for(int i = 1; i <= n; i++) cin>>b[i];
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
for(int i = 1; i <= n; i++){
diff1[i] = max(a[i].first - b[i], 0);
diff2[i] = max(a[i+1].first - b[i], 0);
diff1[i] = max(diff1[i], diff1[i-1]);
}
for(int i = n-1; i >= 1; i--) diff2[i] = max(diff2[i], diff2[i+1]);
vector<pair<int, int>> ans;
for(int i = 1; i <= n+1; i++){
ans.push_back(make_pair(a[i].second, max(diff1[i-1], diff2[i])));
}
sort(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++) cout<<ans[i].second<<" ";
}
Compilation message (stderr)
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i = 0; i < ans.size(); i++) cout<<ans[i].second<<" ";
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |