답안 #445612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445612 2021-07-19T04:29:21 Z jamezzz Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
144 ms 7920 KB
#include <bits/stdc++.h>
using namespace std;

int n, a, b[200005], c[200005], pmx[200005], smx[200005];
typedef pair<int, int> ii;
vector<ii> v;

int main(){
    scanf("%d", &n);
    for (int i = 0; i <= n; ++i){
        scanf("%d", &a);
        v.push_back(ii(a, i));
    }
    for (int i = 0; i < n; ++i){
        scanf("%d", &b[i]);
    }
    sort(v.begin(), v.end());
    sort(b, b + n);
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        ans = max(ans, v[i].first - b[i - 1]);
        c[v[0].second] = ans;
    }
    int sfx = 0;
    for (int i = n; i >= 1; --i){
        sfx = max(sfx, v[i].first - b[i - 1]);
        smx[i] = sfx;
    }
    smx[n + 1] = 0;
    for (int i = 1; i <= n; ++i){
        pmx[i] = max(pmx[i - 1], v[i - 1].first - b[i - 1]);
        c[v[i].second] = max(pmx[i], smx[i + 1]);
    }
    for (int i = 0; i <= n; ++i){
        printf("%d ", c[i]);
    }

}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
ho_t1.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
ho_t1.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 118 ms 7204 KB Output is correct
34 Correct 124 ms 7320 KB Output is correct
35 Correct 123 ms 7100 KB Output is correct
36 Correct 127 ms 7616 KB Output is correct
37 Correct 125 ms 7920 KB Output is correct
38 Correct 121 ms 7732 KB Output is correct
39 Correct 118 ms 6832 KB Output is correct
40 Correct 117 ms 6848 KB Output is correct
41 Correct 116 ms 6864 KB Output is correct
42 Correct 117 ms 6832 KB Output is correct
43 Correct 116 ms 6756 KB Output is correct
44 Correct 118 ms 6448 KB Output is correct
45 Correct 118 ms 6548 KB Output is correct
46 Correct 114 ms 6452 KB Output is correct
47 Correct 108 ms 6348 KB Output is correct
48 Correct 144 ms 6360 KB Output is correct
49 Correct 117 ms 6960 KB Output is correct
50 Correct 127 ms 7140 KB Output is correct
51 Correct 124 ms 6948 KB Output is correct
52 Correct 117 ms 6904 KB Output is correct
53 Correct 120 ms 6960 KB Output is correct