Submission #201321

# Submission time Handle Problem Language Result Execution time Memory
201321 2020-02-10T07:58:15 Z parsa_mobed Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
524 ms 14840 KB
#include <bits/stdc++.h>

using namespace std;
#define pii pair <int , int>
#define F first
#define S second
const int N = 2e5 + 10;
int a[N], b[N], p[N], ans[N];

bool cmp(int i, int j) {return a[i] < a[j];}

int main()
{
    int n; cin >> n;
    for (int i = 1; i <= n + 1; i++) cin >> a[i], p[i] = i;
    for (int i = 1; i <= n; i++) cin >> b[i];
    sort(b + 1, b + n + 1);
    sort(p + 1, p + n + 2, cmp);
    set <pii> st;
    for (int i = 1; i <= n; i++) st.insert({-1*max(a[p[i]] - b[i], 0), i});
    ans[p[n+1]] = (*st.begin()).F;
    for (int i = n + 1; i >= 2; i--) {
        st.erase({-1*max(a[p[i - 1]] - b[i - 1], 0), i-1});
        st.insert({-1*max(a[p[i]] - b[i - 1], 0), i-1});
        ans[p[i - 1]] = (*st.begin()).F;
    }
    for (int i = 1; i <= n + 1; i++) cout << -1*ans[i] << " ";
    cout << "\n";


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 9 ms 504 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 8 ms 376 KB Output is correct
21 Correct 8 ms 504 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 8 ms 376 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 8 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 8 ms 504 KB Output is correct
29 Correct 8 ms 632 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 9 ms 504 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 8 ms 376 KB Output is correct
21 Correct 8 ms 504 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 8 ms 376 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 8 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 8 ms 504 KB Output is correct
29 Correct 8 ms 632 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 427 ms 13880 KB Output is correct
34 Correct 466 ms 14420 KB Output is correct
35 Correct 420 ms 13944 KB Output is correct
36 Correct 442 ms 14340 KB Output is correct
37 Correct 462 ms 14840 KB Output is correct
38 Correct 453 ms 14712 KB Output is correct
39 Correct 502 ms 13688 KB Output is correct
40 Correct 511 ms 13560 KB Output is correct
41 Correct 521 ms 13688 KB Output is correct
42 Correct 508 ms 13944 KB Output is correct
43 Correct 496 ms 13816 KB Output is correct
44 Correct 398 ms 13176 KB Output is correct
45 Correct 406 ms 13304 KB Output is correct
46 Correct 414 ms 13176 KB Output is correct
47 Correct 390 ms 13460 KB Output is correct
48 Correct 403 ms 13432 KB Output is correct
49 Correct 523 ms 13980 KB Output is correct
50 Correct 523 ms 14072 KB Output is correct
51 Correct 524 ms 14076 KB Output is correct
52 Correct 518 ms 14072 KB Output is correct
53 Correct 516 ms 14088 KB Output is correct