# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
819397 | AdamGS | Cake 3 (JOI19_cake3) | C++17 | 2971 ms | 22952 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;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
const int LIM=2e5+7;
pair<ll,ll>T[LIM], dp[LIM];
multiset<ll>S;
vector<pair<ll,ll>>rollback;
ll akt, n, m;
void upd(int x) {
S.insert(T[x].nd);
akt+=T[x].nd;
if(S.size()>m-2) {
rollback.pb({T[x].nd, *S.begin()});
akt-=*S.begin();
S.erase(S.begin());
} else rollback.pb({T[x].nd, -1});
}
void undo() {
if(rollback.back().nd!=-1) {
akt+=rollback.back().nd;
S.insert(rollback.back().nd);
}
akt-=rollback.back().st;
S.erase(S.find(rollback.back().st));
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... |