답안 #763002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763002 2023-06-22T02:17:34 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
109 ms 9972 KB
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 200'000;
pair<int, int> A[MAXN+1];
int B[MAXN];
int N;
int main()
{
    scanf("%d", &N);
    for(int i=0; i<N+1; ++i)
    {
        scanf("%d", &A[i].first);
        A[i].second = i;
    }
    for(int i=0; i<N; ++i) scanf("%d", B+i);
    sort(A, A+N+1); sort(B, B+N);
    vector<int> p(1), q(1);
    for(int i=0; i<N; ++i)
        p.push_back(max(p.back(),A[i].first-B[i]));
    for(int i=N-1; i>=0; --i)
        q.push_back(max(q.back(),A[i+1].first-B[i]));
    reverse(q.begin(), q.end());
    vector<int> ans(N+1);
    for(int i=0; i<=N; ++i)
        ans[A[i].second] = max(p[i], q[i]);
    for(int i=0; i<=N; ++i) printf("%d ", ans[i]);
    puts("");
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     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].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for(int i=0; i<N; ++i) scanf("%d", B+i);
      |                            ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 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 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 320 KB Output is correct
24 Correct 2 ms 352 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 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 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 320 KB Output is correct
24 Correct 2 ms 352 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 105 ms 8912 KB Output is correct
34 Correct 89 ms 9168 KB Output is correct
35 Correct 79 ms 9032 KB Output is correct
36 Correct 78 ms 9648 KB Output is correct
37 Correct 93 ms 9964 KB Output is correct
38 Correct 80 ms 9972 KB Output is correct
39 Correct 82 ms 9116 KB Output is correct
40 Correct 77 ms 9288 KB Output is correct
41 Correct 82 ms 9632 KB Output is correct
42 Correct 109 ms 9724 KB Output is correct
43 Correct 76 ms 9504 KB Output is correct
44 Correct 74 ms 9168 KB Output is correct
45 Correct 80 ms 9268 KB Output is correct
46 Correct 74 ms 9264 KB Output is correct
47 Correct 77 ms 9064 KB Output is correct
48 Correct 97 ms 9240 KB Output is correct
49 Correct 79 ms 9820 KB Output is correct
50 Correct 80 ms 9792 KB Output is correct
51 Correct 82 ms 9924 KB Output is correct
52 Correct 76 ms 9916 KB Output is correct
53 Correct 79 ms 9952 KB Output is correct