Submission #342699

# Submission time Handle Problem Language Result Execution time Memory
342699 2021-01-02T16:25:17 Z blue Just Long Neckties (JOI20_ho_t1) C++11
100 / 100
473 ms 18624 KB
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int A[200001];

int main()
{
    int N;
    cin >> N;

    for(int i = 0; i < N+1; i++) cin >> A[i];

    int I[N+1];
    for(int i = 0; i < N+1; i++) I[i] = i;
    sort(I, I+N+1, [] (int p, int q)
    {
        return A[p] < A[q];
    });

    int B[N];
    for(int i = 0; i < N; i++) cin >> B[i];
    sort(B, B+N);

    multiset<int> strange;
    for(int i = 0; i < N; i++) strange.insert(max(A[I[i]] - B[i], 0));

    int res[N+1];

    res[I[N]] = *strange.rbegin();

    for(int i = N-1; i >= 0; i--)
    {
        strange.erase(strange.find(max(A[I[i]] - B[i], 0)));
        strange.insert(max(A[I[i+1]] - B[i], 0));

        res[I[i]] = *strange.rbegin();
    }
    for(int i = 0; i < N+1; i++) cout << res[i] << ' ';
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 3 ms 492 KB Output is correct
19 Correct 3 ms 492 KB Output is correct
20 Correct 3 ms 492 KB Output is correct
21 Correct 3 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 3 ms 492 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 492 KB Output is correct
30 Correct 4 ms 492 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 3 ms 492 KB Output is correct
19 Correct 3 ms 492 KB Output is correct
20 Correct 3 ms 492 KB Output is correct
21 Correct 3 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 3 ms 492 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 492 KB Output is correct
30 Correct 4 ms 492 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
33 Correct 355 ms 17588 KB Output is correct
34 Correct 367 ms 18284 KB Output is correct
35 Correct 338 ms 17644 KB Output is correct
36 Correct 361 ms 18156 KB Output is correct
37 Correct 404 ms 18624 KB Output is correct
38 Correct 364 ms 18540 KB Output is correct
39 Correct 417 ms 17376 KB Output is correct
40 Correct 411 ms 17388 KB Output is correct
41 Correct 447 ms 17580 KB Output is correct
42 Correct 418 ms 17516 KB Output is correct
43 Correct 473 ms 17388 KB Output is correct
44 Correct 315 ms 16860 KB Output is correct
45 Correct 319 ms 17004 KB Output is correct
46 Correct 315 ms 16876 KB Output is correct
47 Correct 302 ms 17316 KB Output is correct
48 Correct 307 ms 17260 KB Output is correct
49 Correct 426 ms 18028 KB Output is correct
50 Correct 423 ms 17900 KB Output is correct
51 Correct 436 ms 17900 KB Output is correct
52 Correct 432 ms 18040 KB Output is correct
53 Correct 421 ms 17900 KB Output is correct