# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1158745 | Hakuna | Art Exhibition (JOI18_art) | C++20 | 107 ms | 12116 KiB |
#include <bits/stdc++.h>
using namespace std;
int n;
pair<long long, long long> p[(int)5e5 + 10];
long long pref[(int) 5e5 + 10];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> p[i].first >> p[i].second;
}
sort(p + 1, p + n + 1);
for (int i = 1; i <= n; i++) {
pref[i] = pref[i - 1] + p[i].second;
}
long long val = 0;
long long ans = 0;
for (int i = 1; i <= n; i++) {
val = max(val, p[i].first - pref[i - 1]);
ans = max(ans, pref[i] - p[i].first + val);
}
cout << ans;
return 0;
}
# | 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... |