# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1173752 | Hanksburger | Cake 3 (JOI19_cake3) | C++20 | 2571 ms | 17648 KiB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<pair<int, int>, null_type, greater<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
int ans[200005], n, m, l=-1, r=-1, sum, ANS=-1e18;
vector<pair<int, int> > vec;
ordered_set s;
void add(int i)
{
s.insert({vec[i].second, i});
int ind=s.order_of_key({vec[i].second, i});
if (ind<m)
{
sum+=vec[i].second;
if (s.size()>m)
sum-=s.find_by_order(m)->first;
}
//cout << "add " << i << ' ' << sum << '\n';
}
void remove(int i)
{
s.erase({vec[i].second, i});
int ind=s.order_of_key({vec[i].second, i});
if (ind<m)
{
sum-=vec[i].second;
if (s.size()>=m)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |