Submission #900149

# Submission time Handle Problem Language Result Execution time Memory
900149 2024-01-07T18:28:00 Z andrei_iorgulescu Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
74 ms 18768 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int n,b[200005];
pair<int,int> a[200005];
int ans[200005];
int d1[200005],d2[200005];
int maxpref[200005],maxsuf[200005];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    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(b + 1,b + n + 1);
    sort(a + 1,a + n + 2);
    for (int i = 1; i <= n; i++)
        d1[i] = abs(a[i].first - b[i]);
    for (int i = 1; i <= n; i++)
        d2[i] = abs(a[i + 1].first - b[i]);
    maxpref[0] = 0;
    maxsuf[n + 1] = 0;
    for (int i = 1; i <= n; i++)
        maxpref[i] = max(maxpref[i - 1],a[i].first - b[i]);
    for (int i = n; i >= 1; i--)
        maxsuf[i] = max(maxsuf[i + 1],a[i + 1].first - b[i]);
    for (int i = 1; i <= n + 1; i++)
        ans[a[i].second] = max(maxpref[i - 1],maxsuf[i]);
    for (int i = 1; i <= n + 1; i++)
        cout << ans[i] << ' ';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10584 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 2 ms 10584 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10584 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 2 ms 10584 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10584 KB Output is correct
14 Correct 1 ms 10584 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 2 ms 10588 KB Output is correct
19 Correct 2 ms 10588 KB Output is correct
20 Correct 2 ms 10588 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 2 ms 10588 KB Output is correct
23 Correct 2 ms 10588 KB Output is correct
24 Correct 2 ms 10720 KB Output is correct
25 Correct 2 ms 10708 KB Output is correct
26 Correct 2 ms 10584 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 2 ms 10588 KB Output is correct
29 Correct 2 ms 10588 KB Output is correct
30 Correct 2 ms 10588 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10584 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 2 ms 10584 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10584 KB Output is correct
14 Correct 1 ms 10584 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 2 ms 10588 KB Output is correct
19 Correct 2 ms 10588 KB Output is correct
20 Correct 2 ms 10588 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 2 ms 10588 KB Output is correct
23 Correct 2 ms 10588 KB Output is correct
24 Correct 2 ms 10720 KB Output is correct
25 Correct 2 ms 10708 KB Output is correct
26 Correct 2 ms 10584 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 2 ms 10588 KB Output is correct
29 Correct 2 ms 10588 KB Output is correct
30 Correct 2 ms 10588 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 66 ms 14420 KB Output is correct
34 Correct 71 ms 18240 KB Output is correct
35 Correct 68 ms 18044 KB Output is correct
36 Correct 73 ms 18516 KB Output is correct
37 Correct 70 ms 18768 KB Output is correct
38 Correct 70 ms 18600 KB Output is correct
39 Correct 73 ms 17716 KB Output is correct
40 Correct 68 ms 17748 KB Output is correct
41 Correct 70 ms 17824 KB Output is correct
42 Correct 69 ms 17744 KB Output is correct
43 Correct 68 ms 17744 KB Output is correct
44 Correct 66 ms 17440 KB Output is correct
45 Correct 67 ms 17344 KB Output is correct
46 Correct 67 ms 17492 KB Output is correct
47 Correct 63 ms 17232 KB Output is correct
48 Correct 64 ms 17216 KB Output is correct
49 Correct 72 ms 18000 KB Output is correct
50 Correct 71 ms 17892 KB Output is correct
51 Correct 74 ms 17848 KB Output is correct
52 Correct 70 ms 18004 KB Output is correct
53 Correct 70 ms 18000 KB Output is correct