답안 #440752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440752 2021-07-02T22:43:48 Z idontreallyknow Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
151 ms 12524 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define SZ(x) ((int)((x).size()))
#define debug(x) cerr << #x << " = " << x << '\n'
const int mx = 2e5+50;
int a[mx], b[mx], c[mx], pref[mx], suff[mx], ord[mx];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<pii> stuff;
    for (int q = 1; q <= n+1; q++) {
        cin >> a[q];
        stuff.emplace_back(a[q],q);
        c[q] = a[q];
    }
    sort(c+1,c+n+2);
    sort(stuff.begin(), stuff.end());
    for (int q = 0; q < SZ(stuff); q++) ord[stuff[q].se] = q+1;
    for (int q = 1; q <= n; q++) cin >> b[q];
    sort(b+1,b+n+1);
    for (int q = 1; q <= n; q++) pref[q] = max(pref[q-1], max(0,c[q]-b[q]));
    for (int q = n+1; q >= 2; q--) suff[q] = max(suff[q+1], max(0,c[q]-b[q-1]));
    for (int q = 1; q <= n+1; q++) {
        cout << max(pref[ord[q]-1], suff[ord[q]+1]) << ' ';
    }
    cout << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 420 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 392 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 392 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 2 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 420 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 392 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 392 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 2 ms 416 KB Output is correct
33 Correct 123 ms 11576 KB Output is correct
34 Correct 133 ms 12180 KB Output is correct
35 Correct 128 ms 11704 KB Output is correct
36 Correct 128 ms 12176 KB Output is correct
37 Correct 139 ms 12524 KB Output is correct
38 Correct 132 ms 12360 KB Output is correct
39 Correct 126 ms 11360 KB Output is correct
40 Correct 126 ms 11412 KB Output is correct
41 Correct 128 ms 11448 KB Output is correct
42 Correct 126 ms 11400 KB Output is correct
43 Correct 124 ms 11412 KB Output is correct
44 Correct 125 ms 10932 KB Output is correct
45 Correct 136 ms 11064 KB Output is correct
46 Correct 122 ms 10940 KB Output is correct
47 Correct 110 ms 11128 KB Output is correct
48 Correct 114 ms 11168 KB Output is correct
49 Correct 132 ms 11752 KB Output is correct
50 Correct 133 ms 11708 KB Output is correct
51 Correct 134 ms 11652 KB Output is correct
52 Correct 129 ms 11788 KB Output is correct
53 Correct 151 ms 11712 KB Output is correct