# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1265084 | ducdev | Art Exhibition (JOI18_art) | C++17 | 101 ms | 8264 KiB |
// Author: 4uckd3v - Nguyen Cao Duc
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 5e5;
const int MOD = 1e9 + 7;
int n;
pair<ll, int> a[MAX_N + 5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen("MAIN.INP", "r")) {
freopen("MAIN.INP", "r", stdin);
freopen("MAIN.OUT", "w", stdout);
};
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second;
};
sort(a + 1, a + n + 1);
ll pref = 0, res = 0, minPref = 1e18;
for (int i = 1; i <= n; i++) {
pref += a[i].second;
minPref = min(minPref, pref - a[i].second - a[i].first);
res = max(res, pref - a[i].first - minPref);
};
cout << res << '\n';
};
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |