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 <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n; cin >> n;
vector<ll> wolne(n + 1);
for(int i = 0; i < n + 1; i++) {
cin >> wolne[i];
}
vector<ll> ter(n);
for(int i = 0; i < n; i++) {
cin >> ter[i];
}
sort(wolne.begin(), wolne.end());
sort(ter.begin(), ter.end());
for(int i = 0; i < n + 1; i++) {
ll mx = 0;
for(int j = 0; j < i; j++) {
mx = max(mx, wolne[j] - ter[j]);
}
for(int j = i; j < n; j++) {
mx = max(mx, wolne[j + 1] - ter[j]);
}
cout << mx << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |