Submission #636904

# Submission time Handle Problem Language Result Execution time Memory
636904 2022-08-30T12:47:31 Z tvladm2009 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
225 ms 10860 KB
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 2 * 1e5 + 5;
pair<int, int> a[MAX_N + 1];
int b[MAX_N + 1], dp1[MAX_N + 1], dp2[MAX_N + 1], answer[MAX_N + 1];
int n;

int main() {
    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 + n + 2);
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; i++) {
        dp1[i] = max(dp1[i - 1], a[i].first - b[i]);
    }
    for (int i = n + 1; i >= 2; i--) {
        dp2[i] = max(dp2[i + 1], a[i].first - b[i - 1]);
    }
    for (int i = 1; i <= n + 1; i++) {
        answer[a[i].second] = max(dp1[i - 1], dp2[i + 1]);
    }
    for (int i = 1; i <= n + 1; i++) {
        cout << answer[i] << " ";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 2 ms 340 KB Output is correct
15 Correct 2 ms 352 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 324 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 3 ms 316 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 312 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 352 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 2 ms 340 KB Output is correct
15 Correct 2 ms 352 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 324 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 3 ms 316 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 312 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 352 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 178 ms 9900 KB Output is correct
34 Correct 195 ms 10336 KB Output is correct
35 Correct 191 ms 10004 KB Output is correct
36 Correct 189 ms 10416 KB Output is correct
37 Correct 225 ms 10860 KB Output is correct
38 Correct 191 ms 10700 KB Output is correct
39 Correct 189 ms 9696 KB Output is correct
40 Correct 184 ms 9792 KB Output is correct
41 Correct 188 ms 9744 KB Output is correct
42 Correct 188 ms 9796 KB Output is correct
43 Correct 180 ms 9732 KB Output is correct
44 Correct 185 ms 9272 KB Output is correct
45 Correct 185 ms 9388 KB Output is correct
46 Correct 179 ms 9244 KB Output is correct
47 Correct 186 ms 9472 KB Output is correct
48 Correct 181 ms 9440 KB Output is correct
49 Correct 182 ms 9952 KB Output is correct
50 Correct 199 ms 9948 KB Output is correct
51 Correct 186 ms 10008 KB Output is correct
52 Correct 189 ms 10000 KB Output is correct
53 Correct 194 ms 9900 KB Output is correct