Submission #991588

# Submission time Handle Problem Language Result Execution time Memory
991588 2024-06-02T14:38:37 Z Irate Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
170 ms 9312 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>>a(n + 2);
    vector<int> b(n + 1);
    for(int i = 1;i <= n + 1;++i){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    for(int i = 1;i <= n;++i){
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    vector<int>pref_mx(n + 1), suff_mx(n + 3);
    for(int i = 1;i <= n;++i){
        pref_mx[i] = pref_mx[i - 1];
        pref_mx[i] = max({pref_mx[i], a[i].first - b[i], 0});
    }
    for(int i = n + 1;i >= 1;--i){
        suff_mx[i] = suff_mx[i + 1];
        suff_mx[i] = max({suff_mx[i], a[i].first - b[i - 1], 0});
    }
    vector<int>ans(n + 2);
    for(int i = 1;i <= n + 1;++i){
        ans[a[i].second] = max(pref_mx[i - 1], suff_mx[i + 1]);
    }
    for(int i = 1;i <= n + 1;++i){
        cout << ans[i] << ' ';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 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 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 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 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 420 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 352 KB Output is correct
18 Correct 1 ms 484 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 496 KB Output is correct
26 Correct 1 ms 488 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 1 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 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 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 420 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 352 KB Output is correct
18 Correct 1 ms 484 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 496 KB Output is correct
26 Correct 1 ms 488 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 1 ms 484 KB Output is correct
33 Correct 132 ms 8276 KB Output is correct
34 Correct 139 ms 8532 KB Output is correct
35 Correct 132 ms 8276 KB Output is correct
36 Correct 137 ms 8784 KB Output is correct
37 Correct 166 ms 9312 KB Output is correct
38 Correct 134 ms 8880 KB Output is correct
39 Correct 129 ms 7940 KB Output is correct
40 Correct 154 ms 8076 KB Output is correct
41 Correct 135 ms 8016 KB Output is correct
42 Correct 134 ms 8020 KB Output is correct
43 Correct 133 ms 8108 KB Output is correct
44 Correct 134 ms 7652 KB Output is correct
45 Correct 128 ms 7764 KB Output is correct
46 Correct 132 ms 7760 KB Output is correct
47 Correct 170 ms 7884 KB Output is correct
48 Correct 139 ms 7764 KB Output is correct
49 Correct 136 ms 8396 KB Output is correct
50 Correct 151 ms 8528 KB Output is correct
51 Correct 135 ms 8528 KB Output is correct
52 Correct 137 ms 8528 KB Output is correct
53 Correct 145 ms 8528 KB Output is correct