Submission #889354

# Submission time Handle Problem Language Result Execution time Memory
889354 2023-12-19T11:51:12 Z Perl32 Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 348 KB
//I wrote this code 4 u <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

signed main(int32_t argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    for (int i = 0; i <= n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    vector<int> pref(n + 2, 0), suf(n + 2, 0);
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = max(pref[i], a[i].first - b[i]);
    }
    for (int i = n - 1; i > -1; --i) {
        suf[i] = max(suf[i + 1], a[i + 1].first - b[i]);
    }
    vector<int> ans(n + 1);
    for (auto [v, i] : a) {
        ans[i] = max(pref[i], suf[i]);
    }
    for (auto x : ans) {
        cout << x << ' ';
    }
}

/*

 */

Compilation message

ho_t1.cpp: In function 'int main(int32_t, char**)':
ho_t1.cpp:38:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |     for (auto [v, i] : a) {
      |               ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -