답안 #1014861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014861 2024-07-05T16:00:02 Z aufan Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
81 ms 12368 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        int n;
        cin >> n;

        vector<int> a(n + 1);
        for (int i = 0; i < n + 1; i++) cin >> a[i];

        vector<int> b(n);
        for (int i = 0; i < n; i++) cin >> b[i];
        sort(b.begin(), b.end());

        vector<int> ord(n + 1);
        iota(ord.begin(), ord.end(), 0);
        sort(ord.begin(), ord.end(), [&](int x, int y) {
                return a[x] < a[y];
        });

        int res = 0;
        for (int i = 0; i < n; i++) {
                res = max(res, a[ord[i]] - b[i]);
        }

        vector<int> ans(n + 1);
        for (int i = n; i >= 0; i--) {
                ans[ord[i]] = res;
                if (i - 1 >= 0) res = max(res, a[ord[i]] - b[i - 1]);
        }

        for (int i = 0; i < n + 1; i++) cout << ans[i] << " \n"[i == n];
        
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 404 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 404 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 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 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 404 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 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 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 71 ms 11532 KB Output is correct
34 Correct 72 ms 12016 KB Output is correct
35 Correct 69 ms 11644 KB Output is correct
36 Correct 65 ms 12056 KB Output is correct
37 Correct 75 ms 12368 KB Output is correct
38 Correct 68 ms 12368 KB Output is correct
39 Correct 65 ms 11348 KB Output is correct
40 Correct 65 ms 11316 KB Output is correct
41 Correct 79 ms 11344 KB Output is correct
42 Correct 66 ms 11348 KB Output is correct
43 Correct 68 ms 11288 KB Output is correct
44 Correct 68 ms 10936 KB Output is correct
45 Correct 64 ms 10836 KB Output is correct
46 Correct 65 ms 10940 KB Output is correct
47 Correct 52 ms 11092 KB Output is correct
48 Correct 51 ms 11092 KB Output is correct
49 Correct 68 ms 11532 KB Output is correct
50 Correct 68 ms 11600 KB Output is correct
51 Correct 81 ms 11644 KB Output is correct
52 Correct 67 ms 11752 KB Output is correct
53 Correct 67 ms 11512 KB Output is correct