Submission #1033935

#TimeUsernameProblemLanguageResultExecution timeMemory
1033935vjudge1Art Exhibition (JOI18_art)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5;
pair<long long,long long> p[N+5];
int n;
int main(){
    cin >> n;
    for(int i = 0; i < n; i++)cin >> p[i].first >> p[i].second;
    sort(p,p+n);
    long long tong = 0;
    int a = 0;
    tong = p[0].second;
    long long res = tong;
    for(int i = 1; i < n; i++){
        tong+= p[i].second;
        if(tong <= p[i].first - p[a].first){
            tong = 0;
            a = i+1;
        } else {
            res = max(res, tong - p[i].first + p[a].first);
        }
    }
    cout << res;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...