Submission #1014662

# Submission time Handle Problem Language Result Execution time Memory
1014662 2024-07-05T08:59:37 Z snpmrnhlol Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
155 ms 11616 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5;
int v[N + 1];
int p[N + 1];
ll sf[N + 1];
int v2[N];
ll ans[N + 1];
int main(){
    int n;
    cin>>n;
    for(int i = 0;i < n + 1;i++){
        cin>>v[i];
        p[i] = i;
    }
    for(int i = 0;i < n;i++){
        cin>>v2[i];
    }
    sort(p, p + n + 1,[&](int a,int b){
         return v[a] < v[b];
    });
    sort(v2,v2 + n);
    for(int i = n;i >= 1;i--){
        sf[i] = max((i != n?sf[i + 1]:0ll),(ll)max(0,v[p[i]] - v2[i - 1]));
    }
    ll cur = 0;
    for(int i = 0;i <= n;i++){
        ans[p[i]] = max(cur,(i == n?0:sf[i + 1]));
        //cout<<cur<<' '<<(i == n?0:sf[i + 1])<<' '<<p[i]<<'\n';
        if(i != n)cur = max(cur,(ll)max(v[p[i]] - v2[i],0));
    }
    for(int i = 0;i <= n;i++){
        cout<<ans[i]<<' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 2 ms 4552 KB Output is correct
20 Correct 2 ms 4580 KB Output is correct
21 Correct 2 ms 4440 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 2 ms 4444 KB Output is correct
25 Correct 2 ms 4444 KB Output is correct
26 Correct 3 ms 4700 KB Output is correct
27 Correct 2 ms 4444 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
29 Correct 2 ms 4440 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 2 ms 4584 KB Output is correct
32 Correct 2 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 2 ms 4552 KB Output is correct
20 Correct 2 ms 4580 KB Output is correct
21 Correct 2 ms 4440 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 2 ms 4444 KB Output is correct
25 Correct 2 ms 4444 KB Output is correct
26 Correct 3 ms 4700 KB Output is correct
27 Correct 2 ms 4444 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
29 Correct 2 ms 4440 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 2 ms 4584 KB Output is correct
32 Correct 2 ms 4444 KB Output is correct
33 Correct 131 ms 11008 KB Output is correct
34 Correct 131 ms 11092 KB Output is correct
35 Correct 129 ms 10892 KB Output is correct
36 Correct 131 ms 11340 KB Output is correct
37 Correct 143 ms 11504 KB Output is correct
38 Correct 155 ms 11616 KB Output is correct
39 Correct 129 ms 10576 KB Output is correct
40 Correct 129 ms 10544 KB Output is correct
41 Correct 131 ms 10668 KB Output is correct
42 Correct 134 ms 10572 KB Output is correct
43 Correct 127 ms 10576 KB Output is correct
44 Correct 139 ms 10324 KB Output is correct
45 Correct 126 ms 10320 KB Output is correct
46 Correct 125 ms 10380 KB Output is correct
47 Correct 121 ms 10316 KB Output is correct
48 Correct 114 ms 10320 KB Output is correct
49 Correct 129 ms 10836 KB Output is correct
50 Correct 132 ms 10836 KB Output is correct
51 Correct 132 ms 10708 KB Output is correct
52 Correct 150 ms 10836 KB Output is correct
53 Correct 134 ms 10816 KB Output is correct