답안 #212508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
212508 2020-03-23T10:00:24 Z DystoriaX Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
150 ms 9336 KB
#include <bits/stdc++.h>

using namespace std;

int n;
pair<int, int> a[200010];
int b[200010];
int ans[200010];

int main(){
    scanf("%d", &n);

    for(int i = 1; i <= n + 1; i++) scanf("%d", &a[i].first), a[i].second = i;
    for(int i = 1; i <= n; i++) scanf("%d", &b[i]);

    sort(a + 1, a + n + 2);
    sort(b + 1, b + n + 1);

    for(int i = 1; i <= n; i++){
        ans[a[n + 1].second] = max(ans[a[n + 1].second], a[i].first - b[i]);
    }

    for(int i = n; i; i--){
        ans[a[i].second] = max(ans[a[i + 1].second], a[i + 1].first - b[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:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
ho_t1.cpp:13:61: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n + 1; i++) scanf("%d", &a[i].first), a[i].second = i;
                                     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:14:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
                                 ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 126 ms 4832 KB Output is correct
34 Correct 134 ms 8800 KB Output is correct
35 Correct 131 ms 8568 KB Output is correct
36 Correct 128 ms 9080 KB Output is correct
37 Correct 136 ms 9336 KB Output is correct
38 Correct 135 ms 9208 KB Output is correct
39 Correct 130 ms 8312 KB Output is correct
40 Correct 131 ms 8312 KB Output is correct
41 Correct 126 ms 8312 KB Output is correct
42 Correct 127 ms 8312 KB Output is correct
43 Correct 125 ms 8312 KB Output is correct
44 Correct 128 ms 7972 KB Output is correct
45 Correct 127 ms 7928 KB Output is correct
46 Correct 123 ms 7928 KB Output is correct
47 Correct 111 ms 7928 KB Output is correct
48 Correct 108 ms 7928 KB Output is correct
49 Correct 133 ms 8440 KB Output is correct
50 Correct 135 ms 8568 KB Output is correct
51 Correct 130 ms 8432 KB Output is correct
52 Correct 150 ms 8440 KB Output is correct
53 Correct 132 ms 8440 KB Output is correct