Submission #1026236

# Submission time Handle Problem Language Result Execution time Memory
1026236 2024-07-17T18:15:28 Z vanea Art Exhibition (JOI18_art) C++14
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());
    ll ans = v[n][1], prev = v[n][1] - v[n][0];
    for(int i = n-1; i > 0; i--) {
        ll curr = prev + v[i][1];
        ll k = v[i][1] - v[i][0];
        if(curr > k) {
            prev = curr;
            ans = max(ans, curr + v[i][0]);
        }
        else {
            prev = curr;
            ans = max(ans, curr + v[i][0]);
        }
    }
    cout << ans;
    return 0;
}
# 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 -