제출 #916511

#제출 시각아이디문제언어결과실행 시간메모리
916511vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
531 ms8476 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define elif else if
#define x first
#define y second
ll n, temp, ans;
pll a[500001];

int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i].x >> a[i].y;
    }
    sort(a+1, a+1+n);
    for(int i=1; i<=n; i++){
        temp=max(temp - a[i].x + a[i-1].x, 0ll)+a[i].y;
        ans=max(ans, temp);
    }
    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...