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>
#define mod 1000000007
#define inf 100000000000000000
using namespace std;
vector<int>num , cmp;
int suf[300001];
int main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
int menge, numm , nummer;
cin >> menge;
for(int i = 0 ; i < menge + 1; i++){
cin >> numm;
cmp.push_back(numm);
}
for(int i = 0 ; i < menge ; i++){
cin >> numm;
num.push_back(numm);
}
sort(num.begin() , num.end());
sort(cmp.begin() , cmp.end());
for(int i = menge - 1 ; i >= 0 ; i--){
// cout << cmp[i + 1] << ' ' << num[i] << "\n";
suf[i] = max(suf[i + 1] , max(0 , cmp[i + 1] - num[i]));
}
assert(5==6);
int pref = 0;
for(int i = 0 ; i < menge + 1; i++){
if(i == 0){
cout << max(suf[i] , pref) << " ";
continue;
}
pref = max(pref , max(0 , cmp[i - 1] - num[i - 1]));
cout << max(suf[i] , pref) << " ";
}
cout << "\n";
}
Compilation message (stderr)
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:10:23: warning: unused variable 'nummer' [-Wunused-variable]
10 | int menge, numm , nummer;
| ^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |