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 <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, out;
bool skipped;
vector<int> employees;
vector<pair<int, int>> neckties;
cin>>n;
neckties.resize(n+1);
employees.resize(n);
for (int i=0;i<n+1;i++){
cin>>neckties[i].first;
neckties[i].second=i;
}
for (int i=0;i<n;i++) cin>>employees[i];
sort(neckties.begin(), neckties.end(), greater<pair<int, int>>());
sort(employees.begin(), employees.end(), greater<int>());
for (int i=0;i<n+1;i++){
out=0;
skipped=false;
for (int j=0;j<n+1;j++){
if (neckties[j].second==i){
skipped=true;
continue;
}
if (skipped) out=max(out, neckties[j].first-employees[j-1]);
else out=max(out, neckties[j].first-employees[j]);
}
cout<<out<<" ";
}
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... |