제출 #1342850

#제출 시각아이디문제언어결과실행 시간메모리
1342850tamir1Just Long Neckties (JOI20_ho_t1)C++20
9 / 100
1095 ms6212 KiB
#include <bits/stdc++.h>
using namespace std;


#define int long long
#define ff first 
#define ss second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back



void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    vector<int> ans(n + 1), b(n);
    for(int i = 0; i <= n; i++) {
        cin >> a[i].ff;
        a[i].ss = i;
    }
    for(int &i : b) cin >> i;
    sort(all(a));
    sort(all(b));
    for(int i = 0; i <= n; i++) {
        int k = 0;
        int answer = 0;
        for(int j = 0; j < n; j++) {
            if(k == i) k++;
            answer = max(answer, max(0LL, a[k++].ff - b[j]));
            // cout << a[k] << " " << b[j] << "\n";
        }
        ans[a[i].ss] = answer;
    }
    for(int i = 0; i <= n; i++) cout << ans[i] << " ";
}   


signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);


    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...