# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316596 | tushar_2658 | Palembang Bridges (APIO15_bridge) | C++14 | 323 ms | 24808 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;
const int maxn = 200005;
using ll = long long;
struct DS {
multiset<int> P, Q;
ll sumP, sumQ;
DS(){
sumP = sumQ = 0;
}
void add(int x){
if(P.empty()){
P.insert(x);
sumP += x;
}else if(*P.rbegin() < x){
Q.insert(x);
sumQ += x;
}else {
P.insert(x);
sumP += x;
}
if(P.size() < Q.size()){
sumP += *Q.begin();
sumQ -= *Q.begin();
P.insert(*Q.begin());
Q.erase(Q.begin());
}
if(P.size() > Q.size() + 1){
# | 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... |