답안 #924501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924501 2024-02-09T06:03:06 Z qwe1rt1yuiop1 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
208 ms 18756 KB
#include <bits/stdc++.h>
// #define int long long
using namespace std;
using pii = pair<int, int>;

void solve()
{
    int n;
    cin >> n;
    vector<pii> a(n + 1);
    for (int i = 0; i <= n; ++i)
        cin >> a[i].first, a[i].second = i;
    vector<int> b(n);
    for (int &i : b)
        cin >> i;
    sort(b.begin(), b.end());
    sort(a.begin(), a.end());

    vector<int> ans(n + 1);
    multiset<int> st;
    for (int i = 1; i <= n; ++i)
        st.emplace(max(0, a[i].first - b[i - 1]));
    ans[a[0].second] = *prev(st.end());
    for (int i = 1; i <= n; ++i)
    {
        st.erase(st.find(max(0, a[i].first - b[i - 1])));
        st.emplace(max(0, a[i - 1].first - b[i - 1]));
        ans[a[i].second] = *prev(st.end());
    }
    for (int i : ans)
        cout << i << ' ';
    cout << '\n';
}

/*
3
4 3 7 6
2 6 4

5
4 7 9 10 11 12
3 5 7 9 11
*/

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

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 137 ms 17492 KB Output is correct
34 Correct 144 ms 18284 KB Output is correct
35 Correct 140 ms 17692 KB Output is correct
36 Correct 141 ms 18036 KB Output is correct
37 Correct 156 ms 18756 KB Output is correct
38 Correct 147 ms 18340 KB Output is correct
39 Correct 190 ms 17492 KB Output is correct
40 Correct 187 ms 17356 KB Output is correct
41 Correct 187 ms 17492 KB Output is correct
42 Correct 188 ms 17748 KB Output is correct
43 Correct 182 ms 17412 KB Output is correct
44 Correct 129 ms 16808 KB Output is correct
45 Correct 130 ms 16976 KB Output is correct
46 Correct 136 ms 16720 KB Output is correct
47 Correct 137 ms 17196 KB Output is correct
48 Correct 133 ms 17356 KB Output is correct
49 Correct 208 ms 17876 KB Output is correct
50 Correct 199 ms 17856 KB Output is correct
51 Correct 196 ms 18180 KB Output is correct
52 Correct 186 ms 18004 KB Output is correct
53 Correct 205 ms 18044 KB Output is correct