Submission #1109455

# Submission time Handle Problem Language Result Execution time Memory
1109455 2024-11-06T18:26:52 Z DobromirAngelov Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
76 ms 10056 KB
#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second

using namespace std;

const int MAXN=2e5+5;

int n;
int a[MAXN];
pair<int,int> h[MAXN];
int pref[MAXN];
int ans[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n;
    for(int i=1;i<=n+1;i++) 
    {
        cin>>h[i].fi;
        h[i].se=i;
    }
    for(int i=1;i<=n;i++) cin>>a[i];

    sort(a+1,a+n+1);
    sort(h+1,h+n+2);

    for(int i=1;i<=n;i++)
    {
        pref[i]=max(pref[i-1], h[i].fi-a[i]);
    }

    ans[h[n+1].se]=pref[n];
    int suff=0;
    for(int i=n;i>=1;i--)
    {
        suff=max(suff, h[i+1].fi-a[i]);
        ans[h[i].se]=max(suff, pref[i-1]);
    }

    for(int i=1;i<=n+1;i++) cout<<ans[i]<<" ";
    cout<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 1 ms 2548 KB Output is correct
15 Correct 2 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 2 ms 2580 KB Output is correct
19 Correct 2 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 2 ms 2556 KB Output is correct
22 Correct 2 ms 2552 KB Output is correct
23 Correct 2 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 2 ms 2384 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2568 KB Output is correct
29 Correct 2 ms 2384 KB Output is correct
30 Correct 2 ms 2384 KB Output is correct
31 Correct 2 ms 2536 KB Output is correct
32 Correct 1 ms 2556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 1 ms 2548 KB Output is correct
15 Correct 2 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 2 ms 2580 KB Output is correct
19 Correct 2 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 2 ms 2556 KB Output is correct
22 Correct 2 ms 2552 KB Output is correct
23 Correct 2 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 2 ms 2384 KB Output is correct
26 Correct 2 ms 2384 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2568 KB Output is correct
29 Correct 2 ms 2384 KB Output is correct
30 Correct 2 ms 2384 KB Output is correct
31 Correct 2 ms 2536 KB Output is correct
32 Correct 1 ms 2556 KB Output is correct
33 Correct 64 ms 9288 KB Output is correct
34 Correct 67 ms 9544 KB Output is correct
35 Correct 64 ms 9468 KB Output is correct
36 Correct 67 ms 9800 KB Output is correct
37 Correct 76 ms 10056 KB Output is correct
38 Correct 72 ms 10012 KB Output is correct
39 Correct 68 ms 9032 KB Output is correct
40 Correct 67 ms 9032 KB Output is correct
41 Correct 65 ms 9032 KB Output is correct
42 Correct 73 ms 9132 KB Output is correct
43 Correct 64 ms 9168 KB Output is correct
44 Correct 66 ms 8772 KB Output is correct
45 Correct 67 ms 8744 KB Output is correct
46 Correct 65 ms 8776 KB Output is correct
47 Correct 61 ms 8776 KB Output is correct
48 Correct 65 ms 8944 KB Output is correct
49 Correct 69 ms 9288 KB Output is correct
50 Correct 67 ms 9288 KB Output is correct
51 Correct 76 ms 9264 KB Output is correct
52 Correct 69 ms 9288 KB Output is correct
53 Correct 72 ms 9288 KB Output is correct