Submission #201457

# Submission time Handle Problem Language Result Execution time Memory
201457 2020-02-10T15:48:44 Z Alexa2001 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
162 ms 7800 KB
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 2e5 + 5;

int dp1[Nmax], dp2[Nmax], A[Nmax], B[Nmax], ans[Nmax];
pair<int,int> ord[Nmax];
int n;

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);

    cin >> n;
    int i;
    for(i=1; i<=n+1; ++i) cin >> ord[i].first, ord[i].second = i;
    for(i=1; i<=n; ++i) cin >> B[i];

    sort(B+1, B+n+1);
    sort(ord+1, ord+n+2);

    for(i=1; i<=n+1; ++i) A[i] = ord[i].first;
    
    for(i=1; i<=n; ++i)
        dp1[i] = max(dp1[i-1], A[i] - B[i]);
    
    for(i=n+1; i>=2; --i)
        dp2[i] = max(dp2[i+1], A[i] - B[i-1]);

    for(i=1; i<=n+1; ++i)
        ans[ord[i].second] = max(dp1[i-1], dp2[i+1]);

    for(i=1; i<=n+1; ++i) cout << 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 376 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 380 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 376 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 380 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 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 380 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 380 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 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 376 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 380 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 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 380 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 380 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 119 ms 7160 KB Output is correct
34 Correct 120 ms 7416 KB Output is correct
35 Correct 121 ms 7316 KB Output is correct
36 Correct 118 ms 7600 KB Output is correct
37 Correct 127 ms 7800 KB Output is correct
38 Correct 162 ms 7700 KB Output is correct
39 Correct 117 ms 6904 KB Output is correct
40 Correct 121 ms 6904 KB Output is correct
41 Correct 129 ms 7028 KB Output is correct
42 Correct 117 ms 6904 KB Output is correct
43 Correct 121 ms 6852 KB Output is correct
44 Correct 120 ms 6496 KB Output is correct
45 Correct 122 ms 6620 KB Output is correct
46 Correct 118 ms 6520 KB Output is correct
47 Correct 111 ms 6376 KB Output is correct
48 Correct 127 ms 6328 KB Output is correct
49 Correct 126 ms 7032 KB Output is correct
50 Correct 119 ms 7032 KB Output is correct
51 Correct 126 ms 7032 KB Output is correct
52 Correct 131 ms 7236 KB Output is correct
53 Correct 124 ms 7052 KB Output is correct