Submission #968302

# Submission time Handle Problem Language Result Execution time Memory
968302 2024-04-23T09:51:15 Z Hugo1729 Art Exhibition (JOI18_art) C++11
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0)->sync_with_stdio(0);

    int n; cin >> n;
    vector<pair<ll,ll>> paint;
    for(int i=0;i<n;i++){
        ll a,b; cin >> a >> b;
        paint.push_back({a,b});
    }

    sort(paint.begin(),paint.end());

    vector<ll> prefsum(n+1,0);
    for(int i=0;i<n;i++)prefsum[i+1]=prefsum[i]+paint[i].second;

    ll ans=0;
    ll m=0;

    for(int i=0;i<n;i++){
        ans=max(ans,prefsum[i+1]-paint[i].first+m);
        m=max(m,paint[i].first-prefsum[i]);
    }

    cout << ans;

    return 0;
}

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