답안 #702547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
702547 2023-02-24T11:15:30 Z guagua0407 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
225 ms 10744 KB
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second


const int mxn=2e5+5;

pair<int,int> a[mxn];
int b[mxn];
int l[mxn];
int r[mxn];
int ans[mxn];

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n+1;i++){
        cin>>a[i].f;
        a[i].s=i;
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++){
        l[i]=max(a[i].f-b[i],0);
        r[i]=max(a[i+1].f-b[i],0);
    }
    for(int i=n;i>=1;i--){
        l[i]=max(l[i+1],l[i]);
        r[i]=max(r[i+1],r[i]);
    }
    int mxl=0;
    for(int i=1;i<=n+1;i++){
        ans[a[i].s]=max(mxl,r[i]);
        if(i<=n) mxl=max(mxl,l[i]);
    }
    for(int i=1;i<=n+1;i++){
        cout<<ans[i]<<' ';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 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 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 324 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 316 KB Output is correct
20 Correct 2 ms 320 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 372 KB Output is correct
29 Correct 2 ms 316 KB Output is correct
30 Correct 2 ms 320 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 2 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 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 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 324 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 316 KB Output is correct
20 Correct 2 ms 320 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 372 KB Output is correct
29 Correct 2 ms 316 KB Output is correct
30 Correct 2 ms 320 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 2 ms 320 KB Output is correct
33 Correct 175 ms 9976 KB Output is correct
34 Correct 194 ms 10272 KB Output is correct
35 Correct 178 ms 9936 KB Output is correct
36 Correct 192 ms 10460 KB Output is correct
37 Correct 186 ms 10744 KB Output is correct
38 Correct 180 ms 10700 KB Output is correct
39 Correct 196 ms 9664 KB Output is correct
40 Correct 180 ms 9664 KB Output is correct
41 Correct 189 ms 9748 KB Output is correct
42 Correct 180 ms 9792 KB Output is correct
43 Correct 190 ms 9708 KB Output is correct
44 Correct 178 ms 9284 KB Output is correct
45 Correct 180 ms 9400 KB Output is correct
46 Correct 225 ms 9308 KB Output is correct
47 Correct 178 ms 9432 KB Output is correct
48 Correct 178 ms 9352 KB Output is correct
49 Correct 223 ms 10080 KB Output is correct
50 Correct 186 ms 9988 KB Output is correct
51 Correct 200 ms 9996 KB Output is correct
52 Correct 195 ms 9936 KB Output is correct
53 Correct 187 ms 9956 KB Output is correct