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 endl '\n'
#define int long long
typedef long long ll;
const int M = 1e5 + 5, MOD = 1e9+7;
int a[M], b[M], n;
bool cmp(int i, int j) {
int x = max(max(a[i]-b[i], 0ll), max(a[j]-b[j], 0ll));
int y = max(max(a[i]-b[j], 0ll), max(a[j]-b[i], 0ll));
return x < y;
}
int check() {
sort(a, a+n);
sort(b, b+n);
/*vector<int> v;
for (int i = 0; i < n; i++) v.push_back(i);
sort(v.begin(), v.end(), cmp);*/
int ans = 0;
for (int i = 0; i < n; i++) ans = max(ans, max(a[i]-b[i], 0ll));
return ans;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
srand(time(0));
cin >> n;
for (int i = 0; i <= n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
for (int i = 0; i <= n; i++) {
swap(a[i], a[n]);
vector<int> tmp(a, a+n);
cout << check() << ' ';
for (int i = 0; i < n; i++) a[i] = tmp[i];
swap(a[i], a[n]);
} cout << endl;
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... |