Submission #678517

# Submission time Handle Problem Language Result Execution time Memory
678517 2023-01-06T06:30:17 Z minhnhatnoe Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;
    vector<pair<ll, ll>> a(n);
    for (int i=0; i<n; i++)
        cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    vector<ll> b(n);
    ll pfs = 0;
    for (int i=0; i<n; i++)
        pfs += a[i].second;

    ll max_after = 0, max_val = 0;
    for (int i=n-1; i>=0; i--){
        max_after = max(max_after, pfs - a[i].first);
        pfs -= a[i].second;
        // pfs -> pf_(l-1)
        max_val = max(max_val, max_after + a[i].first - pfs);
    }
    cout << max_val << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -