Submission #567253

#TimeUsernameProblemLanguageResultExecution timeMemory
567253milisavJust Long Neckties (JOI20_ho_t1)C++14
9 / 100
244 ms2208 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...