Submission #833070

# Submission time Handle Problem Language Result Execution time Memory
833070 2023-08-21T22:00:08 Z jae Just Long Neckties (JOI20_ho_t1) C++17
9 / 100
1000 ms 15820 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]));
    }
    
    vi res(n + 1);

    for(int i{ 0 }; i <= n; ++i) {
        auto ans{ --strange.end() };
        res[a[i].second] = *ans;

        if(i == n) break;
        strange.erase(lower_bound(ALL(strange), a[i + 1].first - b[i]));
        strange.insert(a[i].first - b[i]);
    }

    for(int a : res) cout << a << ' ';

    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 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 7 ms 340 KB Output is correct
15 Correct 17 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 27 ms 464 KB Output is correct
18 Correct 22 ms 368 KB Output is correct
19 Correct 23 ms 340 KB Output is correct
20 Correct 22 ms 468 KB Output is correct
21 Correct 22 ms 340 KB Output is correct
22 Correct 21 ms 468 KB Output is correct
23 Correct 23 ms 340 KB Output is correct
24 Correct 25 ms 448 KB Output is correct
25 Correct 36 ms 468 KB Output is correct
26 Correct 32 ms 460 KB Output is correct
27 Correct 32 ms 460 KB Output is correct
28 Correct 30 ms 340 KB Output is correct
29 Correct 22 ms 340 KB Output is correct
30 Correct 27 ms 340 KB Output is correct
31 Correct 31 ms 460 KB Output is correct
32 Correct 34 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 7 ms 340 KB Output is correct
15 Correct 17 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 27 ms 464 KB Output is correct
18 Correct 22 ms 368 KB Output is correct
19 Correct 23 ms 340 KB Output is correct
20 Correct 22 ms 468 KB Output is correct
21 Correct 22 ms 340 KB Output is correct
22 Correct 21 ms 468 KB Output is correct
23 Correct 23 ms 340 KB Output is correct
24 Correct 25 ms 448 KB Output is correct
25 Correct 36 ms 468 KB Output is correct
26 Correct 32 ms 460 KB Output is correct
27 Correct 32 ms 460 KB Output is correct
28 Correct 30 ms 340 KB Output is correct
29 Correct 22 ms 340 KB Output is correct
30 Correct 27 ms 340 KB Output is correct
31 Correct 31 ms 460 KB Output is correct
32 Correct 34 ms 468 KB Output is correct
33 Execution timed out 1026 ms 15820 KB Time limit exceeded
34 Halted 0 ms 0 KB -