# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671691 | Dan4Life | Palembang Bridges (APIO15_bridge) | C++17 | 139 ms | 9272 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 int long long
#define fi first
#define se second
#define pb push_back
using pii = pair<int,int>;
#define all(a) a.begin(),a.end()
#define sz(a) (int)a.size()
const int maxn = (int)1e5+10;
const int LINF = (int)1e18;
vector<int> v;
vector<pii> seg;
set<pii> bef,dur,aft;
int t, n, tot, ans=LINF;
int a[maxn], b[maxn];
priority_queue<int> p1;
priority_queue<int,vector<int>,greater<int>> p2;
int sum, x;
void adjust(){
while(!p1.empty() and sz(p1)>sz(p2))
x=p1.top(), p1.pop(),p2.push(x), sum+=2*x;
while(!p2.empty() and sz(p1)<sz(p2))
x=p2.top(), p2.pop(),p1.push(x), sum-=2*x;
}
void add(int x){
if(p1.empty() or p1.top()>=x) p1.push(x), sum-=x;
else p2.push(x), sum+=x; adjust();
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... |