Submission #889357

# Submission time Handle Problem Language Result Execution time Memory
889357 2023-12-19T11:54:04 Z Perl32 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
86 ms 10836 KB
//I wrote this code 4 u <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

signed main(int32_t argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    for (int i = 0; i <= n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    vector<int> pref(n + 2, 0), suf(n + 2, 0);
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = max(pref[i], a[i].first - b[i]);
    }
    for (int i = n - 1; i > -1; --i) {
        suf[i] = max(suf[i + 1], a[i + 1].first - b[i]);
    }
    vector<int> ans(n + 1);
    for (int i = 0; i <= n; ++i) {
        ans[a[i].second] = max(pref[i], suf[i]);
    }
    for (auto x : ans) {
        cout << x << ' ';
    }
}

/*

 */
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 456 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 1 ms 388 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 456 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 1 ms 388 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 508 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 456 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 1 ms 388 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 508 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 71 ms 9904 KB Output is correct
34 Correct 70 ms 10460 KB Output is correct
35 Correct 68 ms 10008 KB Output is correct
36 Correct 86 ms 10552 KB Output is correct
37 Correct 71 ms 10836 KB Output is correct
38 Correct 71 ms 10824 KB Output is correct
39 Correct 69 ms 9768 KB Output is correct
40 Correct 69 ms 9812 KB Output is correct
41 Correct 68 ms 9908 KB Output is correct
42 Correct 69 ms 9844 KB Output is correct
43 Correct 73 ms 9660 KB Output is correct
44 Correct 66 ms 9296 KB Output is correct
45 Correct 67 ms 9552 KB Output is correct
46 Correct 67 ms 9296 KB Output is correct
47 Correct 68 ms 9460 KB Output is correct
48 Correct 64 ms 9552 KB Output is correct
49 Correct 74 ms 10060 KB Output is correct
50 Correct 71 ms 10064 KB Output is correct
51 Correct 71 ms 10256 KB Output is correct
52 Correct 70 ms 10052 KB Output is correct
53 Correct 70 ms 9964 KB Output is correct