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;
#define pb push_back
#define fir first
#define sec second
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(1);
int n;
vector <pair<int,int>> ties;
cin>>n;
int pecat[n+1];
for (int i=0; i<=n; i++)
{
int a;
cin>>a;
ties.pb({a,i});
}
vector <int> empl;
for (int i=0; i<n; i++)
{
int a;
cin>>a;
empl.pb(a);
}
sort(ties.begin(), ties.end());
sort(empl.begin(), empl.end());
int weird = 0;
for (int i=0; i<n; i++)
{
weird = max(weird, ties[i].fir-empl[i]);
}
for (int i=n; i>0; i--)
{
pecat[ties[i].sec] = weird;
weird = max (weird, ties[i].fir - empl[i-1]);
}
pecat[ties[0].sec] = weird;
for (int i=0; i<=n; i++)
{
cout<<pecat[i]<<" ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |