제출 #566912

#제출 시각아이디문제언어결과실행 시간메모리
566912RealSnakeJust Long Neckties (JOI20_ho_t1)C++14
9 / 100
1079 ms6832 KiB
#include "bits/stdc++.h"
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long
#define mod 1000000007

ofstream fout(".out");
ifstream fin(".in");

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    int b[n];
    vector<pair<int, int>> a;
    for(int i = 0; i < n + 1; i++) {
        int x;
        cin >> x;
        a.push_back({x, i});
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++)
        cin >> b[i];
    sort(b, b + n);
    int ans[n + 1];
    for(int i = 0; i < n + 1; i++) {
        int x = 0, j = 0, k = 0;
        while(j < n) {
            if(k == i) {
                k++;
                continue;
            }
            x = max(x, a[k].first - b[j]);
            j++;
            k++;
        }
        ans[a[i].second] = x;
    }
    for(int i = 0; i < n + 1; i++)
        cout << ans[i] << " ";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...