Submission #893095

#TimeUsernameProblemLanguageResultExecution timeMemory
893095AndreyArt Exhibition (JOI18_art)C++14
100 / 100
148 ms20936 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,a,b,sb = 0,sm = -LLONG_MAX,ans = 0;
    cin >> n;
    vector<pair<long long,long long>> haha(n);
    for(long long i = 0; i < n; i++) {
        cin >> a >> b;
        haha[i] = {a,b};
    }
    sort(haha.begin(),haha.end());
    for(long long i = 0; i < n; i++) {
        sm = max(sm,haha[i].first-sb);
        sb+=haha[i].second;
        ans = max(ans,sb+sm-haha[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...