Submission #1026204

# Submission time Handle Problem Language Result Execution time Memory
1026204 2024-07-17T17:13:30 Z vanea Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll NINF = -1e18;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<array<ll, 2>> v(n+1);
    vector<ll> pref(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> v[i][0] >> v[i][1];
    }
    sort(v.begin(), v.end());
    for(int i = 1; i <= n; i++) {
        pref[i] = v[i][1] + pref[i-1];
    }
    ll ans = pref[1];
    ll mx = 0;
    for(int i = 2; i <= n; i++) {
        ll curr = pref[i] - (v[i][0] - v[1][0]);
        curr += mx;
        ans = max(ans, curr);
        mx = max(mx, v[i][0] - v[1][0] - pref[i-1]);
    }
    cout << ans;
}
# 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 -