Submission #951129

# Submission time Handle Problem Language Result Execution time Memory
951129 2024-03-21T07:44:38 Z star Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
83 ms 14888 KB
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n;

    vector<pair<LL,int>> a(n+1);
    vector<LL> b(n);
    for (int i=0; i<n+1; 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());

    vector<LL> left(n+1, 0), right(n+1, 0);

    for (int i=0; i<n; i++)
    {
        left[i+1] = max(left[i], max(a[i].first-b[i], 0LL));
        right[i+1] = max(right[i], max(a[n-i].first-b[n-i-1], 0LL));
    }

    vector<int> res(n+1);

    for (int i=0; i<n+1; i++)
    {
        int id = a[i].second;
        res[id] = max(left[i], right[n-i]);
    }
    for (int i = 0; i < n+1; i++)
    {
        if (i) cout << " ";
        cout << res[i];
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 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 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 524 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 360 KB Output is correct
26 Correct 1 ms 360 KB Output is correct
27 Correct 1 ms 580 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 360 KB Output is correct
30 Correct 1 ms 360 KB Output is correct
31 Correct 1 ms 360 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 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 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 524 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 360 KB Output is correct
26 Correct 1 ms 360 KB Output is correct
27 Correct 1 ms 580 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 360 KB Output is correct
30 Correct 1 ms 360 KB Output is correct
31 Correct 1 ms 360 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
33 Correct 70 ms 13756 KB Output is correct
34 Correct 72 ms 14356 KB Output is correct
35 Correct 71 ms 13800 KB Output is correct
36 Correct 70 ms 14464 KB Output is correct
37 Correct 81 ms 14888 KB Output is correct
38 Correct 75 ms 14580 KB Output is correct
39 Correct 71 ms 13640 KB Output is correct
40 Correct 79 ms 13604 KB Output is correct
41 Correct 76 ms 13700 KB Output is correct
42 Correct 75 ms 13604 KB Output is correct
43 Correct 70 ms 13620 KB Output is correct
44 Correct 69 ms 13224 KB Output is correct
45 Correct 73 ms 13444 KB Output is correct
46 Correct 71 ms 12984 KB Output is correct
47 Correct 70 ms 13536 KB Output is correct
48 Correct 78 ms 13452 KB Output is correct
49 Correct 73 ms 14096 KB Output is correct
50 Correct 74 ms 13892 KB Output is correct
51 Correct 74 ms 14116 KB Output is correct
52 Correct 83 ms 14092 KB Output is correct
53 Correct 75 ms 13904 KB Output is correct