Submission #1114725

# Submission time Handle Problem Language Result Execution time Memory
1114725 2024-11-19T13:22:23 Z tkwiatkowski Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 592 KB
#include<bits/stdc++.h>
#ifdef _DEBUG
#define ls(x) << (x) << ", "
#define lv(x) << #x << ": " << flush << (x) << ", "
#define pr(x) cout << "Line: " << __LINE__ << ", " x << endl;
#else
#define ls(x)
#define lv(x)
#define pr(x) ;
#endif
using namespace std;
typedef unsigned int uint;

struct Neckle {
    int a;
    uint i;
};

bool operator<(Neckle a, Neckle b) {
    return a.a < b.a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    uint n;
    cin >> n;
    vector<Neckle> a(n+1), b(n);
    for (uint i = 0; i < n+1; i++) {
        cin >> a[i].a;
        a[i].i = i;
    }
    for (uint i = 0; i < n; i++) {
        cin >> b[i].a;
        b[i].i = i;
    }
    // if (n == 1) {
    //     cout << abs((int)a[1].a - (int)b[0].a) << ' '
    //          << abs((int)a[0].a - (int)b[0].a);
    //     return 0;
    // }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> pref(n), suff(n);
    pref[0] = 0;
    for (uint i = 1; i < n + 1; i++) {
        pr(lv(i) lv(a[i].a) lv(b[i].a))
        pref[i] = max(pref[i - 1], a[i - 1].a - b[i - 1].a);
    }
    suff[n] = 0;
    // suff[i] = a[i+1].a - b[i].a
    for (uint i = n-1; i + 1 > 0; i--) {
        pr(lv(i) lv(a[i + 1].a) lv(b[i].a))
        suff[i] = max(suff[i+1], a[i+1].a - b[i].a);
    }
    vector<uint> mapping(n+1);
    for (uint i = 0; i < n+1; i++) {
        mapping[a[i].i] = i;
        pr(lv(i) lv(a[i].a) lv(a[i].i) lv(mapping[a[i].i]))
    }
    for (uint i = 0; i < n+1; i++) {
        uint k = mapping[i];
        pr(lv(i) lv(k) lv(suff[k]) lv(pref[k]))
        uint result = max(suff[k], pref[k]);
        cout << result << " ";
        pr(lv(i) lv(k) lv(result))
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -