# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
943939 | kim | Fireworks (APIO16_fireworks) | C++17 | 438 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |