Submission #502770

# Submission time Handle Problem Language Result Execution time Memory
502770 2022-01-06T14:59:53 Z TheTrapper Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
105 ms 15468 KB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vpl=vector<pll>;
using vstr=vector<string>;
using sll=set<ll>;
using spl=set<pll>;
ll INF=1e18;
#define PI 3.14159265
ll MOD=1e9+7;



pll ntie[200005];
ll employ[200005];
ll beforeceo[200005];
ll afterceo[200005];
ll result[200005];
bool Compare(pll p,pll q)
{
    return p.first<q.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n=0;
    cin >> n;
    for(ll i=1;i<=n+1;i++)
    {
        pll neck;
        cin >> neck.first;
        neck.second=i;
        ntie[i]=neck;
    }
    for(ll i=1;i<=n;i++)
    {
        cin >> employ[i];
    }
    sort(ntie+1,ntie+n+2,Compare);
    sort(employ+1,employ+n+1);
    beforeceo[0]=0;
    for(ll i=1;i<=n+1;i++)
    {
        beforeceo[i]=max(beforeceo[i-1],max(ntie[i].first-employ[i],0LL));
    }
    afterceo[0]=0;
    for(ll i=n;i>=1;i--)
    {
        afterceo[i]=max(afterceo[i+1],max(ntie[i+1].first-employ[i],0LL));
    }
    for(ll i=1;i<=n+1;i++)
    {
        ll ceo=ntie[i].second;
        ll ans=max(beforeceo[i-1],afterceo[i]);
        //cout << "DEBUG " <<  beforeceo[i-1] << " " << afterceo[i] << '\n';
        result[ceo]=ans;
    }
    for(ll i=1;i<=n+1;i++)
    {
        cout << result[i] << " ";
    }
    cout << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 456 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 456 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 87 ms 14428 KB Output is correct
34 Correct 96 ms 14992 KB Output is correct
35 Correct 89 ms 14464 KB Output is correct
36 Correct 87 ms 15060 KB Output is correct
37 Correct 95 ms 15468 KB Output is correct
38 Correct 89 ms 15264 KB Output is correct
39 Correct 105 ms 14276 KB Output is correct
40 Correct 103 ms 14216 KB Output is correct
41 Correct 90 ms 14456 KB Output is correct
42 Correct 93 ms 14312 KB Output is correct
43 Correct 102 ms 14312 KB Output is correct
44 Correct 83 ms 13796 KB Output is correct
45 Correct 90 ms 13952 KB Output is correct
46 Correct 90 ms 13848 KB Output is correct
47 Correct 79 ms 14144 KB Output is correct
48 Correct 70 ms 14140 KB Output is correct
49 Correct 96 ms 14664 KB Output is correct
50 Correct 91 ms 14644 KB Output is correct
51 Correct 95 ms 14660 KB Output is correct
52 Correct 87 ms 14660 KB Output is correct
53 Correct 92 ms 14684 KB Output is correct