# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425402 | penguinhacker | Palembang Bridges (APIO15_bridge) | C++14 | 79 ms | 5828 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>
using namespace std;
#define ll long long
#define ar array
const int mxN=1e5;
int n, k;
ll add, ans, tot, p[mxN];
vector<ar<int, 2>> v;
priority_queue<int> lo;
priority_queue<int, vector<int>, greater<int>> hi;
void ins(int x) {
if (lo.empty()||x<=lo.top())
lo.push(x), tot-=x;
else
hi.push(x), tot+=x;
if (lo.size()>hi.size()+1) {
int x=lo.top(); lo.pop();
tot+=2*x, hi.push(x);
}
if (hi.size()>lo.size()) {
int x=hi.top(); hi.pop();
tot-=2*x, lo.push(x);
}
}
ll get() {
return tot+(lo.size()-hi.size())*lo.top();
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |