Submission #655582

# Submission time Handle Problem Language Result Execution time Memory
655582 2022-11-04T18:46:21 Z happypotato Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
291 ms 9252 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    pair<int, int> a[n + 2];
    int b[n + 1];
    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);
    int ans[n + 2];
    for (int i = 1; i <= n + 1; i++) ans[i] = 0;
    int cur = 0;
    for (int i = 1; i <= n; i++) {
        cur = max(cur, max(a[i].first - b[i], 0));
        ans[a[i + 1].second] = max(ans[a[i + 1].second], cur);
    }
    cur = 0;
    for (int i = n + 1; i >= 2; i--) {
        cur = max(cur, max(a[i].first - b[i - 1], 0));
        ans[a[i - 1].second] = max(ans[a[i - 1].second], cur);
    }
    for (int i = 1; i <= n + 1; i++) cout << ans[i] << ' ';
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 308 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 312 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 268 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 312 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 308 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 312 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 268 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 312 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 237 ms 8368 KB Output is correct
34 Correct 219 ms 8732 KB Output is correct
35 Correct 291 ms 8408 KB Output is correct
36 Correct 213 ms 8916 KB Output is correct
37 Correct 227 ms 9252 KB Output is correct
38 Correct 248 ms 9100 KB Output is correct
39 Correct 213 ms 8140 KB Output is correct
40 Correct 202 ms 8164 KB Output is correct
41 Correct 239 ms 8268 KB Output is correct
42 Correct 218 ms 8192 KB Output is correct
43 Correct 202 ms 8164 KB Output is correct
44 Correct 203 ms 7836 KB Output is correct
45 Correct 203 ms 7892 KB Output is correct
46 Correct 241 ms 7748 KB Output is correct
47 Correct 218 ms 7756 KB Output is correct
48 Correct 239 ms 7852 KB Output is correct
49 Correct 246 ms 8424 KB Output is correct
50 Correct 250 ms 8376 KB Output is correct
51 Correct 213 ms 8368 KB Output is correct
52 Correct 218 ms 8400 KB Output is correct
53 Correct 244 ms 8488 KB Output is correct