Submission #936631

# Submission time Handle Problem Language Result Execution time Memory
936631 2024-03-02T12:25:22 Z kitlix Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
227 ms 21708 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    int curid = 0;
    for (auto& [el, id] : a) {
        cin >> el;
        id = curid++;
    }
    vector<int> b(n);
    for (auto& el : b)
        cin >> el;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> ans(n + 1);
    multiset<int> cur;
    for (int i = 1; i <= n; ++i)
        cur.insert(max(a[i].first - b[i - 1], 0ll));
    ans[a[0].second] = *cur.rbegin();
    for (int i = 1; i <= n; ++i) {
        cur.extract(max(a[i].first - b[i - 1], 0ll));
        cur.insert(max(a[i - 1].first - b[i - 1], 0ll));
        ans[a[i].second] = *cur.rbegin();
    }
    for (auto el : ans)
        cout << el << ' ';
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 456 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 456 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 528 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 636 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 456 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 528 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 636 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 155 ms 20560 KB Output is correct
34 Correct 159 ms 21368 KB Output is correct
35 Correct 156 ms 20692 KB Output is correct
36 Correct 154 ms 21112 KB Output is correct
37 Correct 169 ms 21708 KB Output is correct
38 Correct 158 ms 21472 KB Output is correct
39 Correct 206 ms 20460 KB Output is correct
40 Correct 204 ms 20376 KB Output is correct
41 Correct 200 ms 20652 KB Output is correct
42 Correct 196 ms 20588 KB Output is correct
43 Correct 208 ms 20400 KB Output is correct
44 Correct 137 ms 19864 KB Output is correct
45 Correct 134 ms 20056 KB Output is correct
46 Correct 133 ms 19792 KB Output is correct
47 Correct 143 ms 20328 KB Output is correct
48 Correct 147 ms 20564 KB Output is correct
49 Correct 221 ms 21112 KB Output is correct
50 Correct 207 ms 21056 KB Output is correct
51 Correct 207 ms 21076 KB Output is correct
52 Correct 227 ms 21016 KB Output is correct
53 Correct 203 ms 20928 KB Output is correct