Submission #1108285

# Submission time Handle Problem Language Result Execution time Memory
1108285 2024-11-03T16:43:51 Z overwatch9 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
298 ms 20296 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector <pair <int, int>> a(n+1);
    vector <int> 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(b.begin(), b.end());
    vector <pair <int, int>> a2 = a;
    sort(a2.begin(), a2.end());
    multiset <int> d;
    for (int i = 1; i < n+1; i++) {
        d.insert(max(0, a2[i].first - b[i-1]));
    }
    vector <int> ans(n+1);
    ans[a2[0].second] = *d.rbegin();
    for (int i = 0; i < n; i++) {
        d.insert(max(0, a2[i].first - b[i]));
        d.erase(d.find(max(0, a2[i+1].first - b[i])));
        ans[a2[i+1].second] = *d.rbegin();
    }
    for (int i = 0; i < n+1; i++)
        cout << ans[i] << ' ';
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 448 KB Output is correct
19 Correct 3 ms 592 KB Output is correct
20 Correct 2 ms 448 KB Output is correct
21 Correct 2 ms 564 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 448 KB Output is correct
19 Correct 3 ms 592 KB Output is correct
20 Correct 2 ms 448 KB Output is correct
21 Correct 2 ms 564 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 220 ms 17328 KB Output is correct
34 Correct 224 ms 19784 KB Output is correct
35 Correct 203 ms 19180 KB Output is correct
36 Correct 214 ms 19708 KB Output is correct
37 Correct 214 ms 20296 KB Output is correct
38 Correct 210 ms 20040 KB Output is correct
39 Correct 251 ms 18824 KB Output is correct
40 Correct 259 ms 18764 KB Output is correct
41 Correct 276 ms 19264 KB Output is correct
42 Correct 264 ms 19016 KB Output is correct
43 Correct 288 ms 18760 KB Output is correct
44 Correct 219 ms 18300 KB Output is correct
45 Correct 198 ms 18504 KB Output is correct
46 Correct 210 ms 18340 KB Output is correct
47 Correct 213 ms 18760 KB Output is correct
48 Correct 208 ms 18760 KB Output is correct
49 Correct 298 ms 19528 KB Output is correct
50 Correct 273 ms 19528 KB Output is correct
51 Correct 276 ms 19528 KB Output is correct
52 Correct 280 ms 19544 KB Output is correct
53 Correct 275 ms 19416 KB Output is correct