답안 #359882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359882 2021-01-27T09:29:20 Z shahriarkhan Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
165 ms 11868 KB
#include<bits/stdc++.h>
using namespace std ;

int main()
{
    int n ;
    scanf("%d",&n) ;
    int a[n+1] , b[n+1] , pref[n+2] = {0} , suf[n+2] = {0} , ans[n+2] = {0} ;
    vector<pair<int,int> > v ;
    v.push_back({0,0}) ;
    for(int i = 1 ; i <= (n+1) ; ++i)
    {
        scanf("%d",&a[i]) ;
        v.push_back({a[i],i}) ;
    }
    for(int i = 1 ; i <= n ; ++i) scanf("%d",&b[i]) ;
    sort(v.begin()+1,v.end()) ;
    sort(b+1,b+n+1) ;
    for(int i = 1 ; i <= n ; ++i)
    {
        pref[i] = max(pref[i-1],v[i].first-b[i]) ;
    }
    for(int i = n ; i >= 1 ; --i)
    {
        suf[i] = max(suf[i+1],v[i+1].first-b[i]) ;
    }
    for(int i = 1 ; i <= (n+1) ; ++i)
    {
        ans[v[i].second] = max(pref[i-1],suf[i]) ;
    }
    for(int i = 1 ; i <= (n+1) ; ++i) printf("%d ",ans[i]) ;
    printf("\n") ;
    return 0 ;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
ho_t1.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         scanf("%d",&a[i]) ;
      |         ~~~~~^~~~~~~~~~~~
ho_t1.cpp:16:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |     for(int i = 1 ; i <= n ; ++i) scanf("%d",&b[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 2 ms 636 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 2 ms 636 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
33 Correct 122 ms 10844 KB Output is correct
34 Correct 131 ms 11364 KB Output is correct
35 Correct 116 ms 11100 KB Output is correct
36 Correct 121 ms 11560 KB Output is correct
37 Correct 123 ms 11868 KB Output is correct
38 Correct 120 ms 11612 KB Output is correct
39 Correct 118 ms 10716 KB Output is correct
40 Correct 122 ms 10588 KB Output is correct
41 Correct 117 ms 10716 KB Output is correct
42 Correct 165 ms 10716 KB Output is correct
43 Correct 117 ms 10588 KB Output is correct
44 Correct 120 ms 10204 KB Output is correct
45 Correct 116 ms 10332 KB Output is correct
46 Correct 114 ms 10204 KB Output is correct
47 Correct 115 ms 10460 KB Output is correct
48 Correct 118 ms 10484 KB Output is correct
49 Correct 120 ms 11008 KB Output is correct
50 Correct 138 ms 11120 KB Output is correct
51 Correct 125 ms 10972 KB Output is correct
52 Correct 126 ms 10972 KB Output is correct
53 Correct 121 ms 11024 KB Output is correct