답안 #977729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977729 2024-05-08T10:11:07 Z UltraFalcon Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
96 ms 19136 KB
#ifndef DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,abm,mmx,fma,popcnt")
#endif

#include <bits/stdc++.h>
#define int long long
using ll = long long;

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;

    vector<int> a(n+1);
    for (auto &x : a) cin >> x;

    vector<int> b(n);
    for (auto &x : b) cin >> x;

    vector<int> sorted_b(b);
    sort(sorted_b.begin(), sorted_b.end());

    vector<pair<int, int>> sorted_idx;
    for (int i=0; i<=n; i++) {
        sorted_idx.push_back({a[i], i});
    }
    sort(sorted_idx.begin(), sorted_idx.end());

    vector<int> pref(n+2, 0);
    for (int i=0; i<n; i++) {
        pref[i+1] = max(pref[i], max(sorted_idx[i].first - sorted_b[i], 0LL));
    }
    vector<int> suff(n+2, 0);
    for (int i=n; i>0; i--) {
        suff[n-i+1] = max(suff[n-i], max(sorted_idx[i].first - sorted_b[i-1], 0LL));
    }

    vector<int> res(n+1, -1);
    for (int i=0; i<=n; i++) {
        res[sorted_idx[i].second] = max(pref[i], suff[n-i]);
    }

    for (auto &x : res) {
        cout << x << " "; 
    }
    cout << "\n";

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 500 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 500 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 760 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 508 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 500 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 760 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 508 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 82 ms 17388 KB Output is correct
34 Correct 92 ms 18260 KB Output is correct
35 Correct 79 ms 18140 KB Output is correct
36 Correct 75 ms 18972 KB Output is correct
37 Correct 76 ms 19136 KB Output is correct
38 Correct 79 ms 18348 KB Output is correct
39 Correct 96 ms 18120 KB Output is correct
40 Correct 77 ms 18376 KB Output is correct
41 Correct 76 ms 17672 KB Output is correct
42 Correct 81 ms 17584 KB Output is correct
43 Correct 77 ms 17348 KB Output is correct
44 Correct 88 ms 16832 KB Output is correct
45 Correct 86 ms 17748 KB Output is correct
46 Correct 76 ms 17144 KB Output is correct
47 Correct 71 ms 18016 KB Output is correct
48 Correct 95 ms 17328 KB Output is correct
49 Correct 83 ms 18768 KB Output is correct
50 Correct 92 ms 18012 KB Output is correct
51 Correct 84 ms 17944 KB Output is correct
52 Correct 85 ms 18012 KB Output is correct
53 Correct 89 ms 18680 KB Output is correct