답안 #587307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587307 2022-07-01T15:43:55 Z stevancv Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
116 ms 10752 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    vector<pair<int, int>> a(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    vector<int> pref(n), suff(n + 1);
    for (int i = 0; i < n; i++) {
        pref[i] = max(0, a[i].first - b[i]);
        if (i > 0) smax(pref[i], pref[i - 1]);
    }
    for (int i = n; i >= 1; i--) {
        suff[i] = max(0, a[i].first - b[i - 1]);
        if (i < n) smax(suff[i], suff[i + 1]);
    }
    vector<int> ans(n + 1);
    for (int i = 0; i <= n; i++) {
        if (i > 0) ans[a[i].second] = pref[i - 1];
        if (i < n) smax(ans[a[i].second], suff[i + 1]);
    }
    for (int i = 0; i <= n; i++) {
        cout << ans[i] << sp;
    }
    cout << en;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 316 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 212 KB Output is correct
3 Correct 1 ms 316 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 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 212 KB Output is correct
3 Correct 1 ms 316 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 83 ms 9928 KB Output is correct
34 Correct 94 ms 10368 KB Output is correct
35 Correct 97 ms 10080 KB Output is correct
36 Correct 87 ms 10444 KB Output is correct
37 Correct 96 ms 10752 KB Output is correct
38 Correct 106 ms 10668 KB Output is correct
39 Correct 99 ms 9756 KB Output is correct
40 Correct 116 ms 9740 KB Output is correct
41 Correct 106 ms 9800 KB Output is correct
42 Correct 92 ms 9772 KB Output is correct
43 Correct 94 ms 9688 KB Output is correct
44 Correct 97 ms 9372 KB Output is correct
45 Correct 103 ms 9348 KB Output is correct
46 Correct 89 ms 9248 KB Output is correct
47 Correct 88 ms 9392 KB Output is correct
48 Correct 108 ms 9408 KB Output is correct
49 Correct 112 ms 10060 KB Output is correct
50 Correct 99 ms 10076 KB Output is correct
51 Correct 88 ms 9996 KB Output is correct
52 Correct 101 ms 9956 KB Output is correct
53 Correct 90 ms 10060 KB Output is correct