답안 #566953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566953 2022-05-23T06:47:41 Z katwamiaw Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
249 ms 8592 KB
#include<bits/stdc++.h>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;

const int Max_n=2e5+10 ;
int a[Max_n] , b[Max_n] , f[Max_n] , c[Max_n] ;
int pref[Max_n] , suff[Max_n] ;
vector<array<int,2>>v ;

int main(){
    int n ; cin >> n ;
    for(int i=0 ; i<n+1 ; i++){
        cin >> a[i] ;
        v.push_back({a[i],i}) ;
    }
    for(int i=0 ; i<n ; i++) cin >> b[i] ;

    sort(a,a+n+1) ;
    sort(v.begin(),v.end()) ;
    sort(b,b+n) ;

    for(int i=0 ; i<n+1 ; i++){
        f[i]=v[i][1] ;
    }

    pref[0]=0 ;
    for(int i=0 ; i<n ; i++){
        int k=max((a[i]-b[i]),0) ;
        pref[i+1]=max(pref[i],k) ;
    }
    suff[n+1]=0 ;
    for(int i=n ; i>=1 ; i--){
        int k=max((a[i]-b[i-1]),0) ;
        suff[i]=max(suff[i+1],k) ;
    }

    for(int i=1 ; i<=n+1 ; i++){
        int ans=max(pref[i-1],suff[i]) ;
        c[f[i-1]]=ans ;
    }

    for(int i=0 ; i<n+1 ; i++) cout << c[i] << ' ' ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 1 ms 340 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 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 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 3 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 328 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 1 ms 340 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 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 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 3 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 328 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 225 ms 7804 KB Output is correct
34 Correct 234 ms 8148 KB Output is correct
35 Correct 212 ms 7896 KB Output is correct
36 Correct 214 ms 8376 KB Output is correct
37 Correct 226 ms 8592 KB Output is correct
38 Correct 220 ms 8508 KB Output is correct
39 Correct 239 ms 7632 KB Output is correct
40 Correct 207 ms 7564 KB Output is correct
41 Correct 223 ms 7640 KB Output is correct
42 Correct 220 ms 7584 KB Output is correct
43 Correct 229 ms 7560 KB Output is correct
44 Correct 201 ms 7308 KB Output is correct
45 Correct 227 ms 7312 KB Output is correct
46 Correct 215 ms 7212 KB Output is correct
47 Correct 232 ms 7184 KB Output is correct
48 Correct 222 ms 7184 KB Output is correct
49 Correct 235 ms 7908 KB Output is correct
50 Correct 239 ms 7800 KB Output is correct
51 Correct 234 ms 7800 KB Output is correct
52 Correct 249 ms 7812 KB Output is correct
53 Correct 239 ms 7784 KB Output is correct