답안 #221870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221870 2020-04-11T10:47:23 Z davooddkareshki Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
319 ms 20440 KB
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long

const int maxn = 5e5+10;

int a[maxn], b[maxn], pr[maxn], sf[maxn], n;
vector<pair<int,int>> A, B;
int ans[maxn];

signed main()
{
    cin>> n;
    for(int i = 1; i <= n+1; i++)
    {
        cin>> a[i];
        A.push_back({a[i],i});
    }
    for(int i = 1; i <= n; i++)
    {
        cin>> b[i];
        B.push_back({b[i],i});
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    for(int i = 1; i <= n; i++)
        pr[i] = max(pr[i-1], A[i-1].F-B[i-1].F);
    for(int i = n+1; i >= 2; i--)
        sf[i] = max(sf[i+1], A[i-1].F-B[i-2].F);

    for(int i = 1; i <= n+1; i++)
        ans[A[i-1].S] = max(sf[i+1], pr[i-1]);
    for(int i = 1; i <= n+1; i++)
        cout<< ans[i] <<" ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 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 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 5 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 4 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 5 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 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 5 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 4 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 6 ms 512 KB Output is correct
15 Correct 7 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 8 ms 640 KB Output is correct
18 Correct 7 ms 512 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 7 ms 512 KB Output is correct
21 Correct 7 ms 512 KB Output is correct
22 Correct 7 ms 616 KB Output is correct
23 Correct 7 ms 640 KB Output is correct
24 Correct 7 ms 512 KB Output is correct
25 Correct 7 ms 640 KB Output is correct
26 Correct 9 ms 512 KB Output is correct
27 Correct 7 ms 640 KB Output is correct
28 Correct 7 ms 640 KB Output is correct
29 Correct 7 ms 512 KB Output is correct
30 Correct 7 ms 512 KB Output is correct
31 Correct 7 ms 640 KB Output is correct
32 Correct 7 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 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 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 5 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 4 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 6 ms 512 KB Output is correct
15 Correct 7 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 8 ms 640 KB Output is correct
18 Correct 7 ms 512 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 7 ms 512 KB Output is correct
21 Correct 7 ms 512 KB Output is correct
22 Correct 7 ms 616 KB Output is correct
23 Correct 7 ms 640 KB Output is correct
24 Correct 7 ms 512 KB Output is correct
25 Correct 7 ms 640 KB Output is correct
26 Correct 9 ms 512 KB Output is correct
27 Correct 7 ms 640 KB Output is correct
28 Correct 7 ms 640 KB Output is correct
29 Correct 7 ms 512 KB Output is correct
30 Correct 7 ms 512 KB Output is correct
31 Correct 7 ms 640 KB Output is correct
32 Correct 7 ms 640 KB Output is correct
33 Correct 310 ms 19136 KB Output is correct
34 Correct 319 ms 19896 KB Output is correct
35 Correct 306 ms 19292 KB Output is correct
36 Correct 301 ms 19796 KB Output is correct
37 Correct 318 ms 20440 KB Output is correct
38 Correct 308 ms 20180 KB Output is correct
39 Correct 304 ms 19532 KB Output is correct
40 Correct 306 ms 19028 KB Output is correct
41 Correct 306 ms 19292 KB Output is correct
42 Correct 312 ms 19156 KB Output is correct
43 Correct 301 ms 19188 KB Output is correct
44 Correct 309 ms 18516 KB Output is correct
45 Correct 305 ms 18644 KB Output is correct
46 Correct 298 ms 18500 KB Output is correct
47 Correct 318 ms 19184 KB Output is correct
48 Correct 317 ms 19028 KB Output is correct
49 Correct 316 ms 19668 KB Output is correct
50 Correct 316 ms 19668 KB Output is correct
51 Correct 315 ms 19668 KB Output is correct
52 Correct 307 ms 19648 KB Output is correct
53 Correct 309 ms 19668 KB Output is correct