Submission #1114633

# Submission time Handle Problem Language Result Execution time Memory
1114633 2024-11-19T09:39:42 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
80 ms 15804 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX=2*1e5+7;

vector<pair<ll, ll>> a;
vector<ll> b;
ll wyn[MAX];
ll pref[MAX];
ll suf[MAX];

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

    ll n, c;
    cin >> n;

    for (int i=0; i<=n; i++){
        cin >> c;
        a.push_back({c, i});
    }

    for (int i=0; i<n; i++){
        cin >> c;
        b.push_back(c);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    pref[0] = 0;
    for (int i=1; i<=n; i++){
        pref[i] = max(pref[i-1], max((ll)0, a[i-1].first-b[i-1]));
    }

    suf[n+1] = 0;

    for (int i=n; i>=1; i--){
        suf[i] = max(suf[i+1], max((ll)0, a[i].first-b[i-1]));
    }

    for (int i=0; i<=n; i++){
        wyn[a[i].second] = max(pref[i], suf[i+1]);
    }

    for (int i=0; i<=n; i++) cout << wyn[i] << " ";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
7 Correct 1 ms 4432 KB Output is correct
8 Correct 1 ms 4600 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 1 ms 4432 KB Output is correct
11 Correct 1 ms 4432 KB Output is correct
12 Correct 1 ms 4432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
7 Correct 1 ms 4432 KB Output is correct
8 Correct 1 ms 4600 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 1 ms 4432 KB Output is correct
11 Correct 1 ms 4432 KB Output is correct
12 Correct 1 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 2 ms 4432 KB Output is correct
16 Correct 1 ms 4608 KB Output is correct
17 Correct 2 ms 4432 KB Output is correct
18 Correct 2 ms 4432 KB Output is correct
19 Correct 2 ms 4432 KB Output is correct
20 Correct 2 ms 4432 KB Output is correct
21 Correct 2 ms 4688 KB Output is correct
22 Correct 2 ms 4432 KB Output is correct
23 Correct 1 ms 4432 KB Output is correct
24 Correct 2 ms 4432 KB Output is correct
25 Correct 1 ms 4432 KB Output is correct
26 Correct 2 ms 4432 KB Output is correct
27 Correct 2 ms 4432 KB Output is correct
28 Correct 2 ms 4432 KB Output is correct
29 Correct 2 ms 4432 KB Output is correct
30 Correct 2 ms 4432 KB Output is correct
31 Correct 2 ms 4432 KB Output is correct
32 Correct 2 ms 4432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
7 Correct 1 ms 4432 KB Output is correct
8 Correct 1 ms 4600 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 1 ms 4432 KB Output is correct
11 Correct 1 ms 4432 KB Output is correct
12 Correct 1 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 2 ms 4432 KB Output is correct
16 Correct 1 ms 4608 KB Output is correct
17 Correct 2 ms 4432 KB Output is correct
18 Correct 2 ms 4432 KB Output is correct
19 Correct 2 ms 4432 KB Output is correct
20 Correct 2 ms 4432 KB Output is correct
21 Correct 2 ms 4688 KB Output is correct
22 Correct 2 ms 4432 KB Output is correct
23 Correct 1 ms 4432 KB Output is correct
24 Correct 2 ms 4432 KB Output is correct
25 Correct 1 ms 4432 KB Output is correct
26 Correct 2 ms 4432 KB Output is correct
27 Correct 2 ms 4432 KB Output is correct
28 Correct 2 ms 4432 KB Output is correct
29 Correct 2 ms 4432 KB Output is correct
30 Correct 2 ms 4432 KB Output is correct
31 Correct 2 ms 4432 KB Output is correct
32 Correct 2 ms 4432 KB Output is correct
33 Correct 65 ms 14020 KB Output is correct
34 Correct 66 ms 14268 KB Output is correct
35 Correct 65 ms 14268 KB Output is correct
36 Correct 69 ms 14520 KB Output is correct
37 Correct 80 ms 14672 KB Output is correct
38 Correct 67 ms 15120 KB Output is correct
39 Correct 65 ms 13752 KB Output is correct
40 Correct 65 ms 13752 KB Output is correct
41 Correct 75 ms 13752 KB Output is correct
42 Correct 69 ms 15804 KB Output is correct
43 Correct 65 ms 13756 KB Output is correct
44 Correct 64 ms 13500 KB Output is correct
45 Correct 66 ms 13496 KB Output is correct
46 Correct 69 ms 13496 KB Output is correct
47 Correct 66 ms 13396 KB Output is correct
48 Correct 63 ms 13916 KB Output is correct
49 Correct 72 ms 14016 KB Output is correct
50 Correct 78 ms 14008 KB Output is correct
51 Correct 68 ms 14032 KB Output is correct
52 Correct 77 ms 13952 KB Output is correct
53 Correct 76 ms 14008 KB Output is correct