# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108380 | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 151 ms | 18368 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int maxn = 5e5 + 10;
pair<int, int> p[maxn];
int n;
int pre[maxn];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
#define TASK "TASK"
if (fopen(TASK".INP", "r")){
freopen(TASK".INP", "r", stdin);
freopen(TASK".OUT", "w", stdout);
}
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) pre[i] = pre[i - 1] + p[i].second;
priority_queue<int, vector<int>, greater<int>> pq;
int ans = 0;
for(int i = 1; i <= n; ++ i) {
pq.push(pre[i - 1] - p[i].first);
ans = max(ans, pre[i] - p[i].first - pq.top());
}
cout << ans;
return 0;
}
// ▒███████▓▒░
// ███▓░░░░░░░████▓
// ░██░░░░░░░░███▓ ░▒
// ██████████████████████████ ██░░░░░░░██▓▓█████▒
// ███████░░░░░░░███░░░░░░░░░░░░░░░███▓ ▓███░░░░░████▒░░░▒████
// █████████████░░░░░░░░░░░░██░░░░░░░░░░░░░░░░░░████████▓▓██░░░███░░░░░░░░░░██░
// ▒██░░░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░░░░▓██████▓▓▓▓██░██▓░░░░░░░░░░░░▒█
// ░███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██▓▓▓▓██▓███████▓████████░░░░░░█▓
// ███▓░░░░░░██░░░░░░░█░░░░░░░░░░░░░█▓░░░░░▒█▓▓▓▓▓▓██▓▓███▓▓▓█▓ ███░░░██▒
// █▓░░░░██░░░░░░░░█▓░░░░░░░░░░░░░░█▓░░░░░░███▓▓▓██▓▓▓▓▓▓▓██ ░█▓░███
// ▒█▒░░░██░░░░░░░░░██░░░░░░░░░░░░░░▓██▓░░░░░░▒█████████▓▓▓███ ▓████░
// ░█▒░░░██░░░░░░░░░░██░░░░░░░░░░░░░░████░░░░░░░░░░▒█████████░▓█ ███
// ██░░░██░░░░░░░░░░▒█▒░░░░░░░░░░░░░██░▓██░░░░░░░░░░░░░░░░█▓░░░█▓
// ▒█▒░░░█▒░░░░░░░░░░▒█▒░░░░░░░░░░░░▓██░░▒██░░░░░░░░░░░░░░░░░░░░▒█░
// ██░░░███░░░░░░░░░░██▒░░░░░░░░░░░▒██░░░░░██░░░░░░░░░░░░░░░░░░░░██
// ██░░░▒███░░░░░░░░████▓░░░░░░█░░░▒██▒░░░░░░██░░░░░░░░█▒▒██░░░░░░██▓
// ██░░░░████░░░░░░██▓ ██░░░░░██░░▒██░█▒░░░░░░██░░░░░░░██▒▒██░░░░░░██░
// ██░░░░██░▒██░░░░█▓ ▒█▒░░░███░▓█▒ ▓█░░░░░░▒█▒░░░░░░▒██░░██░░░░░░██░
// ░█▒░░░░██░░░███▒▒█▒ ▓█░░░█████░ ▓██░░░░░██░░░░░░░██░░░██░░░░░░████▒ ▓
// ██░░░░░██▒░░▓█░████ ▓█▓▒█░█▓ ░██▓░░░░██░░░░░░▓█▓░░▒██▓░░░░░░░▓██████
// ░█▒░░░░░██▓░░██ ░███ ░ ▒███░░██░░░░░░▒██░░░████▓░░░░░░▒██▓
// ███████████░▒█▒ ██ ▒████▒░░░░░▒██░░░░██▒▓██████▓
// ██░██░ ██░░░░░███░░░░▒██░░██
// ▒█▓▒█░ ▓█░░░░▒██▓░░░░░██▓░░█▒
// ██░█▓ ██ ▓▓░░░▒███▒░░░░░▒██░░█▓
// ██░▒█ ██████████████ █▒░░█████░░░░░░░██░░█▒
// ██░░██ █▓▓▓▓▓▓▓▓▓▓▓██ ░█░▓██▓██▓░░░░░░░██░░█▒
// ██░████░ ██▓▓▓▓▓▓▓▓██ █████ ░██░░░░░░░███░░█░
// ██████▓██ █▓▓▓▓▓▓██ ▓█▓░ ▒█▓░░░░░░░░██░░░█░
// ███ ██░░██░ █████ ░██░░░░░░░░░██▒░░░█░
// ██░░░░███░ ░░██▓░░░░░░░░░░██▒░░░░█░
// ██░░▓░░░███▓░ ▒███▓░░░░░░░░░░░███░░░░░░█▒
// ██████▓░░░▒████▓░ ░█▓░░░░░░░░░░██▓ ██▓░░░░▒█
// ▓██ ░████████████████▓▓░░░░░░░░░░▒██████▓▒▒▒▓██▓ ▒███▒░░██
// ▒ ▒█████░ ▓█▓▓▓▓███▓████████████░░░▒█████░░▒█▒ ▒████
// ▒▓████▓ ▒█▓▓▓▓▓▓███▓▓▓▓▓▓▓▓▓█ ▓███████
// ▓███▓▓▓▓ ░█▓▓▓▓███▓▓▓▓▓▓▓▓▓▓██ ▓▓▓▓▓████▓
// ░████░███▓▓▓█▓ ░████▓██▓██████████▓▒ ░▓▓▓▓████▓██▓
// ░███ ░█████ ██▓▓██▓▓▒███▓███▒ ███░▓▓▓▓███░▒████▒
// ▒██▒░██ ██████ ███ ▓▓ ░█████ ░████████░ ░██░▓▓█▒ ░██
//███████████████▒░░░░▒█░ ██░░░█░ ▒▓ ▓█░░░▒█░ ██░░▒▓████▓▓░ ████
// █▒░░░░░░░██▒░░░░░░░▒█░ ▒█▒░████▓▓▓▓█████████▒ ▓████▓██░ ██▓░░▓▓░░▒▓▓███░ ███░▒██
// ░██░░▒██▓░░░░░░░░░░▓██ ░██░ ░ ▒█▓▓▓▓▓▓▓▓▓▓██████████░ █▓ ██▒░░░▒▓░▒▓▓░░█████████████▓░░░░░██
// ██▓░░░░░░░░░░▒██▓ █▓ ░█░ ███████████▓▓▓▓▓███████████████▒██████░░░▓▓▓▓░░░░░░░░███▒░░░░░░░░░██
// ▓█░░░░░░░░▓██▒ ░█▓███████▓▓▓▓██████████████▓▓▓▓▓▓▓▓▓▓████▓ ▓██▓▓▓░░░░░░░░░░░░░▓██▒░░░███
// █▒░░░░░░▓██ ████▓▓▓▓▓████ ██▓▓▓▓▓▓▓█░████▓▓▓▓▓▓▓████▒ ▓▓▓▓███▒░░░░░░░░░░░▒█████▒
// █▓░░░░░██ ░███▓▓▓████▓ ██▓▓▓▓▓▓▓▓█▒ ░█████████▒ ██ ▓▓ ░▓ ███▒░░░░░░░░░███
// ██▒░░░██ █▓▓██████ ░██▓▓▓▓▓▓▓▓▓█▒ ░███████████ ░▓▓▓▓▓▓▓▒ ▒██▒░░░░░░░██
// ███░░█▓ ██▓█████████████████████████████▒ █████████ ██░░░░░░██
// ▓█████ ████████▒ ░████████ █▒░░░░██
// ░███████ ███████▒ █▒░░▓█
// ██████░ ██████ ██░▓█▒
// ▒███ ███ ████░
//
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... |