답안 #541497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541497 2022-03-23T17:02:32 Z NyanCatTW1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
257 ms 21760 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;
typedef long long LL;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;

    vector<pair<LL, int> > A(N + 1);
    vector<LL> B(N);
    for (int i = 0; i <= N; i++) {
        cin >> A[i].first;
        A[i].second = i;
    }

    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    multiset<LL> vals;
    for (int i = 0; i < N; i++) {
        // After - Before;
        vals.insert(max(A[i + 1].first - B[i], 0LL));
    }

    vector<LL> ans(N + 1);
    for (int i = 0; i <= N; i++) {
        if (i) {
            vals.erase(vals.find(max(A[i].first - B[i - 1], 0LL)));
            vals.insert(max(A[i - 1].first - B[i - 1], 0LL));
        }

        ans[A[i].second] = *vals.rbegin();
    }

    for (int i = 0; i <= N; i++) {
        if (i) cout << ' ';
        cout << ans[i];
    }

    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 404 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 3 ms 460 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 420 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 404 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 3 ms 460 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 420 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 201 ms 20304 KB Output is correct
34 Correct 210 ms 21232 KB Output is correct
35 Correct 185 ms 20556 KB Output is correct
36 Correct 191 ms 21012 KB Output is correct
37 Correct 197 ms 21760 KB Output is correct
38 Correct 185 ms 21456 KB Output is correct
39 Correct 238 ms 20328 KB Output is correct
40 Correct 237 ms 20352 KB Output is correct
41 Correct 240 ms 20576 KB Output is correct
42 Correct 244 ms 20420 KB Output is correct
43 Correct 240 ms 20356 KB Output is correct
44 Correct 164 ms 19916 KB Output is correct
45 Correct 167 ms 19912 KB Output is correct
46 Correct 163 ms 19724 KB Output is correct
47 Correct 164 ms 20348 KB Output is correct
48 Correct 163 ms 20356 KB Output is correct
49 Correct 254 ms 21072 KB Output is correct
50 Correct 241 ms 20956 KB Output is correct
51 Correct 254 ms 20988 KB Output is correct
52 Correct 257 ms 20988 KB Output is correct
53 Correct 241 ms 20988 KB Output is correct