# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943975 | kim | Fireworks (APIO16_fireworks) | C++17 | 402 ms | 72412 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 endl '\n'
using ll=long long;
struct A{
multiset<ll> L,R;
ll mn;
A():mn(0){}
void insert(ll x){
if(L.empty()) L.emplace(x), R.emplace(x);
else if(x<*L.rbegin()){
mn+=*L.rbegin()-x;
L.emplace(x), L.emplace(x);
R.emplace(*L.rbegin()), L.erase(prev(L.end()));
}
else if(x>*R.begin()){
mn+=x-*R.begin();
R.emplace(x), R.emplace(x);
L.emplace(*R.begin()), R.erase(R.begin());
}
else L.emplace(x), R.emplace(x);
}
A& operator+=(A o){
if(L.size()<o.L.size()) swap(*this,o);
for(auto &e:o.L){
if(e<*R.begin()) L.emplace(e);
else{
mn+=e-*R.begin();
# | 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... |