Submission #1332001

#TimeUsernameProblemLanguageResultExecution timeMemory
1332001AgageldiArt Exhibition (JOI18_art)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

#define N 1000005

#define int long long
const int inf = INT_MAX;
const int M = 998244353;

int n, p[N], sm[N], ans, sum;
pair <int,int> a[N];

signed main() {
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + n + 1);
    sm[0] = 0;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        sm[i] = sm[i - 1] + a[i].second;
        for(int j = i - 1; j >= 1; j--) {
            ans = max(ans, sm[i] - sm[j - 1] - a[i].first + a[j].first);
        }
    }
    cout << ans << endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...