Submission #390744

# Submission time Handle Problem Language Result Execution time Memory
390744 2021-04-16T20:20:21 Z timmyfeng Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
107 ms 7876 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 200001;

int a[N], b[N], order[N], prefix[N], suffix[N], ans[N];

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

    int n;
    cin >> n;

    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    iota(order, order + n + 1, 0);
    sort(order, order + n + 1, [&](int i, int j) {
        return a[i] < a[j];
    });

    sort(b, b + n);

    for (int i = 0; i < n; ++i) {
        prefix[i + 1] = max(prefix[i], a[order[i]] - b[i]);
    }

    for (int i = n; i > 0; --i) {
        suffix[i - 1] = max(suffix[i], a[order[i]] - b[i - 1]);
    }

    for (int i = 0; i < n + 1; ++i) {
        ans[order[i]] = max(prefix[i], suffix[i]);
    }

    for (int i = 0; i < n + 1; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 2 ms 372 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 372 KB Output is correct
29 Correct 1 ms 372 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 2 ms 372 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 372 KB Output is correct
29 Correct 1 ms 372 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 101 ms 7176 KB Output is correct
34 Correct 104 ms 7432 KB Output is correct
35 Correct 103 ms 7164 KB Output is correct
36 Correct 104 ms 7592 KB Output is correct
37 Correct 106 ms 7876 KB Output is correct
38 Correct 107 ms 7764 KB Output is correct
39 Correct 103 ms 6844 KB Output is correct
40 Correct 101 ms 6852 KB Output is correct
41 Correct 103 ms 6980 KB Output is correct
42 Correct 103 ms 6844 KB Output is correct
43 Correct 103 ms 6852 KB Output is correct
44 Correct 100 ms 6668 KB Output is correct
45 Correct 104 ms 6644 KB Output is correct
46 Correct 100 ms 6572 KB Output is correct
47 Correct 86 ms 6344 KB Output is correct
48 Correct 86 ms 6500 KB Output is correct
49 Correct 105 ms 6988 KB Output is correct
50 Correct 105 ms 7096 KB Output is correct
51 Correct 107 ms 6984 KB Output is correct
52 Correct 107 ms 7008 KB Output is correct
53 Correct 104 ms 6980 KB Output is correct