Submission #699508

#TimeUsernameProblemLanguageResultExecution timeMemory
699508Galal012Art Exhibition (JOI18_art)C++17
50 / 100
1065 ms12104 KiB
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
signed main()
{
    IOS;
    int n, ans = 0;
    cin >> n;
    pair <int, int> pr[n+1];
    pr[0].first = pr[0].second = 0;
    for (int i = 1; i <= n; i++)
        cin >> pr[i].first >> pr[i].second;
    sort(pr, pr+n+1);
    for (int i = 1; i <= n; i++)
        pr[i].second += pr[i-1].second;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            int tot = pr[j].second-pr[i-1].second;
            ans = max(ans, tot - (pr[j].first-pr[i].first));
        }

    }
    cout << ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...