답안 #540923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
540923 2022-03-22T02:08:17 Z LittleCube Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
238 ms 10792 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

int N, A[200005], B[200005], pre[2][200005], order[200005], ans[200005];

signed main()
{
    cin >> N;
    for (int i = 1; i <= N + 1; i++)
        cin >> A[i];
    for (int i = 1; i <= N + 1; i++)
        order[i] = i;
    sort(order + 1, order + 2 + N, [&](int i, int j)
         { return A[i] < A[j]; });
    sort(A + 1, A + 2 + N);
    for (int i = 1; i <= N; i++)
        cin >> B[i];
    sort(B + 1, B + 1 + N);
    for (int j = 0; j <= 1; j++)
        for (int i = 1; i <= N; i++)
            pre[j][i] = max(0, A[i + j] - B[i]);
    for (int i = 1; i <= N; i++)
        pre[0][i] = max(pre[0][i], pre[0][i - 1]);
    for (int i = N; i >= 1; i--)
        pre[1][i] = max(pre[1][i], pre[1][i + 1]);
    for (int i = 1; i <= N + 1; i++)
        ans[order[i]] = max(pre[0][i - 1], pre[1][i]);
    for (int i = 1; i <= N + 1; i++)
        cout << ans[i] << " \n"[i == N + 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 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 312 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 360 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 412 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 316 KB Output is correct
31 Correct 2 ms 316 KB Output is correct
32 Correct 3 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 360 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 412 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 316 KB Output is correct
31 Correct 2 ms 316 KB Output is correct
32 Correct 3 ms 320 KB Output is correct
33 Correct 205 ms 9912 KB Output is correct
34 Correct 217 ms 10284 KB Output is correct
35 Correct 217 ms 9976 KB Output is correct
36 Correct 205 ms 10432 KB Output is correct
37 Correct 227 ms 10792 KB Output is correct
38 Correct 207 ms 10612 KB Output is correct
39 Correct 236 ms 9780 KB Output is correct
40 Correct 224 ms 9872 KB Output is correct
41 Correct 218 ms 9772 KB Output is correct
42 Correct 207 ms 9716 KB Output is correct
43 Correct 221 ms 9632 KB Output is correct
44 Correct 216 ms 9348 KB Output is correct
45 Correct 218 ms 9416 KB Output is correct
46 Correct 230 ms 9348 KB Output is correct
47 Correct 191 ms 9336 KB Output is correct
48 Correct 202 ms 9356 KB Output is correct
49 Correct 221 ms 9956 KB Output is correct
50 Correct 218 ms 10108 KB Output is correct
51 Correct 237 ms 9960 KB Output is correct
52 Correct 212 ms 9976 KB Output is correct
53 Correct 238 ms 10136 KB Output is correct