Submission #1108574

# Submission time Handle Problem Language Result Execution time Memory
1108574 2024-11-04T13:31:32 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
long n,i;
long long t,r;
long long s[500001],f[500002];
pair<long long,long> a[500001];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
//    freopen("CodeForces.inp","r",stdin);
//    freopen("CodeForces.out","w",stdout);
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i].first>>a[i].second;
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
        s[i]=s[i-1]+a[i].second;
    for(i=n;i>0;i--)
        f[i]=max(f[i+1],s[i]-a[i].first);
    for(i=1;i<=n;i++)
    {
        r=max(r,f[i]-t+a[i].first);
        t+=a[i].second;
    }
    cout<<r;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -