Submission #999674

# Submission time Handle Problem Language Result Execution time Memory
999674 2024-06-16T04:22:33 Z Icelast Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
void solve(){
    int n;
    cin >> n;
    vector<pair<ll, ll>> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin()+1, a.end());
    ll mx = 0, ans = 0;
    vector<ll> pf(n+1, 0);
    for(int i = 1; i <= n; i++){
        pf[i] = pf[i-1]+a[i].second;
    }
    for(int i = 1; i <= n; i++){
        ans = max(ans, pf[i]-a[i].first + mx);
        mx = max(mx, a[i].first-pf[i-1]);
    }
    cout << ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -