제출 #813558

#제출 시각아이디문제언어결과실행 시간메모리
813558manhlinh1501Art Exhibition (JOI18_art)C++17
50 / 100
1016 ms16088 KiB
/// @author : Hoang Manh Linh
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
using i64 = long long;
using pll = pair<i64, i64>;


int n;
pll a[MAXN];
i64 sum[MAXN];
i64 ans = 0;

int main(int argc, char **argv) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;

    for(int i = 1; i <= n; i++)
        cin >> a[i].first >> a[i].second;

    sort(a + 1, a + n + 1);

    for(int i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + a[i].second;

    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++)
            ans = max(ans, (sum[j] - sum[i - 1]) - (a[j].first - a[i].first));
    }

    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...