답안 #566923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566923 2022-05-23T06:24:52 Z MrDeboo Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
334 ms 22472 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int arr[n+1];
    for(auto &i:arr)cin>>i;
    int a[n+1];
    for(int i=0;i<=n;i++)a[i]=arr[i];
    sort(a,a+n+1);
    int b[n];
    for(auto &i:b)cin>>i;
    sort(b,b+n);
    map<int,int>ans;
    int pre[n+1];
    int suf[n+1];
    for(int i=0;i<n;i++){
        pre[i]=max(0ll,a[i]-b[i]);
        if(i)pre[i]=max(pre[i],pre[i-1]);
    }
    for(int i=n;i>=1;i--){
        suf[i]=max(0ll,a[i]-b[i-1]);
        if(i!=n)suf[i]=max(suf[i],suf[i+1]);
    }
    for(int i=0;i<=n;i++){
        if(i)ans[a[i]]=pre[i-1];
        if(i!=n)ans[a[i]]=max(ans[a[i]],suf[i+1]);
    }
    for(int i=0;i<=n;i++)cout<<ans[arr[i]]<<' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 283 ms 21172 KB Output is correct
34 Correct 319 ms 22184 KB Output is correct
35 Correct 282 ms 21232 KB Output is correct
36 Correct 297 ms 21896 KB Output is correct
37 Correct 295 ms 22472 KB Output is correct
38 Correct 311 ms 22220 KB Output is correct
39 Correct 283 ms 21184 KB Output is correct
40 Correct 282 ms 21020 KB Output is correct
41 Correct 293 ms 21312 KB Output is correct
42 Correct 303 ms 21292 KB Output is correct
43 Correct 289 ms 21060 KB Output is correct
44 Correct 297 ms 20604 KB Output is correct
45 Correct 274 ms 20716 KB Output is correct
46 Correct 285 ms 20544 KB Output is correct
47 Correct 176 ms 11140 KB Output is correct
48 Correct 169 ms 11096 KB Output is correct
49 Correct 318 ms 21736 KB Output is correct
50 Correct 293 ms 21828 KB Output is correct
51 Correct 316 ms 21748 KB Output is correct
52 Correct 305 ms 21980 KB Output is correct
53 Correct 334 ms 21820 KB Output is correct