Submission #854241

# Submission time Handle Problem Language Result Execution time Memory
854241 2023-09-26T13:02:43 Z LeVanThuc Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 4440 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
    if(x<y)
    {
        x=y;
        return 1;
    }
    return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
    if(x>y)
    {
        x=y;
        return 1;
    }
    return 0;
}
void online()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef thuc
    freopen("input.INP","r",stdin);
    freopen("output.OUT","w",stdout);
#endif
}
const ll N=2e5+10,inf=1e18;
pll a[N];
ll b[N],f[N],n;
int main()
{
    online();
    cin>>n;
    for(int i=1;i<=n+1;i++)
    {
        cin>>a[i].fi;
        a[i].se=i;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    for(int i=n+1;i>=2;i--)
    {
        f[i]=a[i].fi-b[i-1];
        f[i]=max(f[i],f[i+1]);
    }
    cout<<f[2]<<' ';
    ll cr=0;
    for(int i=1;i<=n;i++)
    {
        maximize(cr,a[i].fi-b[i]);
        cout<<max(cr,f[i+2])<<' ';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -