Submission #502769

# Submission time Handle Problem Language Result Execution time Memory
502769 2022-01-06T14:59:04 Z TheTrapper Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 324 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 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -