답안 #883678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883678 2023-12-05T17:01:32 Z atom Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
150 ms 18136 KB
#include "bits/stdc++.h"
// @JASPER'S BOILERPLATE
using namespace std;
using ll = long long;

#define fi first
#define se second
#ifdef JASPER
#include "debug.h"
#else
#define debug(...) 166
#endif

using pii = pair < int, int >;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int n;
pair <int, int> a[N];
int b[N];

int ans[N];
void run_case() {
    cin >> n;
    for (int i = 1; i <= n + 1; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i = 1; i <= n; ++i) cin >> b[i];

    sort(a + 1, a + 2 + n);
    sort(b + 1, b + 1 + n);

    set <int> st;
    for (int i = 1; i <= n; ++i) {
        st.insert(max(0, a[i].first - b[i]));
    }

    ans[a[n + 1].second] = *st.rbegin();

    for (int i = n; i >= 1; --i) {
        st.erase(max(0, a[i].first - b[i]));
        st.insert(max(0, a[i + 1].first - b[i]));
        ans[a[i].second] = *st.rbegin();
    }

    for (int i = 1; i <= n + 1; ++i) 
        cout << ans[i] << " \n"[i == n + 1];
}

/*
    3 4 6 7
    2 4 6
*/

signed main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    int Test = 1;
    //cin >> Test;
    for (int test = 1; test <= Test; test++){

        run_case();
    }
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2548 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 0 ms 2508 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2548 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 0 ms 2508 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 2 ms 2524 KB Output is correct
23 Correct 1 ms 2648 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2660 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2552 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2548 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 0 ms 2508 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 2 ms 2524 KB Output is correct
23 Correct 1 ms 2648 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2660 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2552 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 126 ms 14164 KB Output is correct
34 Correct 141 ms 17092 KB Output is correct
35 Correct 112 ms 13604 KB Output is correct
36 Correct 146 ms 17492 KB Output is correct
37 Correct 149 ms 17964 KB Output is correct
38 Correct 150 ms 18136 KB Output is correct
39 Correct 86 ms 9420 KB Output is correct
40 Correct 94 ms 9352 KB Output is correct
41 Correct 88 ms 9300 KB Output is correct
42 Correct 106 ms 9440 KB Output is correct
43 Correct 86 ms 9204 KB Output is correct
44 Correct 74 ms 8016 KB Output is correct
45 Correct 75 ms 8268 KB Output is correct
46 Correct 74 ms 8024 KB Output is correct
47 Correct 74 ms 9812 KB Output is correct
48 Correct 83 ms 9808 KB Output is correct
49 Correct 93 ms 9368 KB Output is correct
50 Correct 89 ms 9552 KB Output is correct
51 Correct 88 ms 9388 KB Output is correct
52 Correct 87 ms 9552 KB Output is correct
53 Correct 88 ms 9556 KB Output is correct