Submission #1108438

# Submission time Handle Problem Language Result Execution time Memory
1108438 2024-11-04T06:52:13 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 2384 KB
#include <bits/stdc++.h>
#define ll long long
#define cst const long long
#define ff first
#define ss second
using namespace std;
ll o,d,m,n,a1,a2,a3,l,r,i,j,x,y,u,v,k,w,z,M,q,p[500005],f[2000005];
cst mod=1e9+7;
pair<ll,ll> a[500005];
void up(ll id,ll l,ll r,ll i,ll v)
{
    if(i<l || i>r) return;
    if(l==r)
    {
        f[id]=v;
        return;
    }
    ll mid=(l+r)/2;
    up(id*2,l,mid,i,v); up(id*2+1,mid+1,r,i,v);
    f[id]=max(f[id*2],f[id*2+1]);
}
ll lay(ll id,ll l,ll r,ll u,ll v)
{
    if(l>r) return 0;
    if(v<l || r<u) return 0;
    if(u<=l && v>=r) return f[id];
    ll mid=(l+r)/2;
    return max(lay(id*2,l,mid,u,v),lay(id*2+1,mid+1,r,u,v));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n;
    for(ll i=1;i<=n;i++) cin >> a[i].ff >> a[i].ss;
    sort(a+1,a+1+n);
    for(ll i=1;i<=n;i++) p[i]=p[i-1]+a[i].ss;
    for(ll i=1;i<=n;i++)
    {
        d=lay(1,1,n,1,i-1);
        w=max(w,d+p[i]-a[i].ff);
        up(1,1,n,i,d-p[i-1]+a[i].ff);
    }
    cout << w;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -