Submission #1229098

#TimeUsernameProblemLanguageResultExecution timeMemory
1229098liamczarArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h>
using namespace std;
int main (){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long n;
    cin >> n;
    vector<pair<long long,long long>> a(n);
    for(int i=0; i<n; i++) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    long long res=0, l=0, tong=0;
    for(int r=0; r<n; r++){
        tong+=a[r].second;
        long long amin=a[l].first;
        long long amax=a[r].first;
        long long ok= tong - (amax - amin);
        res=max(res,ok);
    }
    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...