# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
204944 | ics0503 | Cake 3 (JOI19_cake3) | C++17 | 3608 ms | 23652 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
long long n, m, allSum = 0;
multiset<long long >L, R; // R is big
void balance() {
if (L.size() == 0 || R.size() == 0)return;
if (R.size() < m) {
long long lmax = (*L.rbegin());
L.erase(L.find(lmax)); R.insert(lmax);
allSum += lmax;
return;
}
long long lmax = (*L.rbegin()), rmin = (*R.begin());
if (lmax > rmin) {
L.erase(L.find(lmax)); R.erase(R.find(rmin));
L.insert(rmin); R.insert(lmax);
allSum += lmax - rmin;
}
}
void add(long long x) {
if (R.size() < m) { R.insert(x); allSum += x; }
else L.insert(x);
balance();
}
void del(long long x) {
if (L.find(x) != L.end())L.erase(L.find(x));
else { R.erase(R.find(x)); allSum -= x; }
컴파일 시 표준 에러 (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... |