Submission #1115352

# Submission time Handle Problem Language Result Execution time Memory
1115352 2024-11-20T11:11:17 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll>> sv;
    for(int i = 0; i < n; ++i)
    {
        ll a, b;
        cin >> a >> b;
        sv.push_back({a, b});
    }
    sort(sv.begin(), sv.end());
    ll sp[n+1];
    sp[0] = 0;
    sp[1] = sv[0].second;
    for(int i = 2; i <= n; ++i)
        sp[i] = sp[i-1] + sv[i-1].second - sv[i-1].first + sv[i-2].first;
    ll mi = 1e18+7;
    ll odp = -1e18-7;
    for(int i = 0; i <= n; ++i)
    {
        mi = min(mi, sp[i]);
        odp = max(odp, sp[i] - mi);
    }
    cout << odp;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -