Submission #991589

# Submission time Handle Problem Language Result Execution time Memory
991589 2024-06-02T14:39:38 Z Irate Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
81 ms 6996 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 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 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 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 1 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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 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 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 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 1 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 64 ms 6280 KB Output is correct
34 Correct 66 ms 6480 KB Output is correct
35 Correct 67 ms 6484 KB Output is correct
36 Correct 69 ms 6812 KB Output is correct
37 Correct 64 ms 6996 KB Output is correct
38 Correct 62 ms 6992 KB Output is correct
39 Correct 61 ms 5960 KB Output is correct
40 Correct 65 ms 5968 KB Output is correct
41 Correct 62 ms 6100 KB Output is correct
42 Correct 65 ms 5972 KB Output is correct
43 Correct 62 ms 5976 KB Output is correct
44 Correct 62 ms 5772 KB Output is correct
45 Correct 81 ms 5716 KB Output is correct
46 Correct 63 ms 5720 KB Output is correct
47 Correct 60 ms 5460 KB Output is correct
48 Correct 61 ms 5464 KB Output is correct
49 Correct 67 ms 6120 KB Output is correct
50 Correct 68 ms 6120 KB Output is correct
51 Correct 66 ms 6128 KB Output is correct
52 Correct 67 ms 6144 KB Output is correct
53 Correct 69 ms 6232 KB Output is correct