Submission #833067

# Submission time Handle Problem Language Result Execution time Memory
833067 2023-08-21T21:56:36 Z jae Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using pi = std::pair<int, int>;

#define REP(i,a,b) for(int i{ a }; i < b; ++i)
#define MP std::make_pair
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()

void solve(int no) {
    int n{};
    cin >> n;

    vector<pi> a(n + 1); // avail ties
    REP(i, 0, n + 1) {
        a[i] = { 0, i };
        cin >> a[i].first;
    }

    vi b(n); // curr ties
    REP(i, 0, n) {
        cin >> b[i];
    }

    sort(ALL(a));
    sort(ALL(b));

    multiset<int> strange{};
    REP(i, 0, n) {
        strange.insert(max(0, a[i + 1].first - b[i]));
    }

    for(int i{ 0 }; i <= n; ++i) {
        cout << *(--strange.end()) << ' ';
        if(i == n) break;
        strange.erase(lower_bound(ALL(strange), a[i + 1].first - b[i]));
        strange.insert(a[i].first - b[i]);
    }

    cout << '\n';
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);

    solve(0);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -