Submission #871132

# Submission time Handle Problem Language Result Execution time Memory
871132 2023-11-10T02:02:26 Z Marco_Escandon Just Long Neckties (JOI20_ho_t1) C++11
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    pair<ll,ll> cad[n+1];ll cad2[n];
    for(int i=0; i<n+1; i++)
    {
        cin>>cad[i].first;
        cad[i].second=i;
    }
    for(int j=0; j<n; j++)
        cin>>cad2[j];
    sort(cad,cad+n+1);
    sort(cad2,cad2+n);
    ll ac[n+4]={ };
    for(int i=n; i>0; i--)
    {
        ac[i]=max(0LL,cad[i].first-cad2[i-1]);
        ac[i]=max(ac[i+1],ac[i]);
    }
    ll act=0;
    vector<pair<ll,ll>> sol;
    sol.push_back({cad[0].second,ac[1]});
    for(int i=0; i<n; i++)
    {
        act=max(act,cad[i].first-cad2[i]);
        sol.push_back({cad[i+1].second,max(ac[i+2],act)});
    }
    for(auto i:sol)
        cout<<i.second<<" ";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -