제출 #390139

#제출 시각아이디문제언어결과실행 시간메모리
390139ioiArt Exhibition (JOI18_art)C++14
100 / 100
596 ms20932 KiB
#include<bits/stdc++.h>

using namespace std;


int main()
{
    int n ;
    cin >> n ;

    vector<pair<long long , long long > > v(n);

    for(auto &it : v)cin >> it.first >> it.second ;

    sort(v.begin() , v.end());
    long long ans = 0 ;
    long long sum = 0 ;
    long long past = 0 ;

    for(int i = n - 1 ; i >= 0 ; i --){
        if(i != n - 1)sum += v[i].second - (past - v[i].first);

        sum = max(sum , v[i].second);
        past = v[i].first ;
        ans = max(ans , sum);
    }

    cout << ans ;

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