Submission #355160

# Submission time Handle Problem Language Result Execution time Memory
355160 2021-01-22T09:38:59 Z kai824 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 364 KB
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<stack>
#include<cmath>
#define Rint register int
#define ll long long
using namespace std;
int n;
struct node{
    int l,v;
}a[500005];
bool cmp(node x,node y){
    return x.l<y.l;
}
int presum[500005];
int temp[500005];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].l>>a[i].v;
    }
    sort(a+1,a+1+n,cmp);
    int maxx1=-0x7fffffff,minn=0x7fffffff,ans=0;
    for(int i=1;i<=n;i++){
        presum[i]=presum[i-1]+a[i].v;
    }
    for(int i=1;i<=n;i++){
        maxx1=presum[i]-a[i].l;
        ans=max(ans,maxx1-minn);
        minn=min(minn,presum[i-1]-a[i].l);
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -