Submission #1075319

#TimeUsernameProblemLanguageResultExecution timeMemory
1075319TheLostSunArt Exhibition (JOI18_art)C++14
50 / 100
1087 ms20828 KiB
#include <bits/stdc++.h>

using namespace std;

int n;
pair<long long, int> pa[500001];

long long maxx = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> pa[i].first >> pa[i].second;
    sort(pa + 1, pa + n + 1);
    for (int i = 1; i <= n; i++)
    {
        long long tong = 0;
        for (int j = i; j <= n; j++)
        {
            tong += pa[j].second;
            maxx = max(maxx, tong - (pa[j].first - pa[i].first));
        };
    };
    cout << maxx;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...