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 long long ll;
int main() {
int n; cin>>n;
vector<pair<ll,int>> a(n+1);
vector <ll> b(n);
for (int i=0; i<=n; i++) {
cin>>a[i].first;
a[i].second=i;
}
for (int i=0; i<n; i++) cin>>b[i];
sort(a.begin(), a.end());
sort(b.rbegin(), b.rend());
for (int i=0; i<=n; i++) {
int aind=0;
ll ans=0;
for (int j=n-1; j>=0; j--) {
if (a[aind].second==i) aind++;
ans=max(ans,max(a[aind].first-b[j],0ll));
aind++;
}
cout<<ans<<" ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |