답안 #227174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227174 2020-04-26T10:09:38 Z ho94949 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
145 ms 7400 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]
     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]
         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]
     for(int i=0; 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 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 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 5 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 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 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 5 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 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 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 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 6 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 6 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 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 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 5 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 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 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 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 6 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 6 ms 384 KB Output is correct
33 Correct 140 ms 6764 KB Output is correct
34 Correct 143 ms 7012 KB Output is correct
35 Correct 141 ms 6760 KB Output is correct
36 Correct 139 ms 7172 KB Output is correct
37 Correct 142 ms 7400 KB Output is correct
38 Correct 142 ms 7400 KB Output is correct
39 Correct 141 ms 6508 KB Output is correct
40 Correct 136 ms 6376 KB Output is correct
41 Correct 144 ms 6512 KB Output is correct
42 Correct 137 ms 6508 KB Output is correct
43 Correct 137 ms 6508 KB Output is correct
44 Correct 139 ms 6120 KB Output is correct
45 Correct 137 ms 6124 KB Output is correct
46 Correct 136 ms 6124 KB Output is correct
47 Correct 127 ms 5996 KB Output is correct
48 Correct 123 ms 5996 KB Output is correct
49 Correct 145 ms 6628 KB Output is correct
50 Correct 144 ms 6632 KB Output is correct
51 Correct 141 ms 6760 KB Output is correct
52 Correct 143 ms 6632 KB Output is correct
53 Correct 143 ms 6640 KB Output is correct