Submission #777388

#TimeUsernameProblemLanguageResultExecution timeMemory
7773881binJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
210 ms21784 KiB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e5 + 5;
ll n, x, b[NMAX], ans[NMAX];
vector<pair<ll, ll>> v;
multiset<ll> s;

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i = 0; i <= n; i++) {
        cin >> x;
        v.emplace_back(x, i);
    }
    for(int i = 0; i < n; i++) cin >> b[i];
    sort(all(v));
    sort(b, b + n);
    for(int i = 0; i < n; i++) s.emplace(v[i + 1].first - b[i]);
    ans[v[0].second] = max(*s.rbegin(), 0LL);
    for(int i = 1; i <= n; i++){
        auto&[x, ix] = v[i];
        s.erase(s.find(x - b[i - 1]));
        s.emplace(v[i - 1].first - b[i - 1]);
        ans[ix] = max(*s.rbegin(), 0LL);
    }
    for(int i = 0; i <= n; i++) cout << ans[i] << ' ';
    return 0;
}

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:26:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   26 |         auto&[x, ix] = v[i];
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...