# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
157734 | TadijaSebez | Sushi (JOI16_sushi) | C++11 | 432 ms | 41968 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;
const int N=400050;
const int S=447;
set<int> pos[N/S];
multiset<pair<int,int>> st[N/S];
int a[N];
int Push(int B, int x)
{
st[B].insert({x,0});
int p;tie(x,p)=*st[B].rbegin();
st[B].erase(--st[B].end());
if(p) pos[B].insert(-p);
return x;
}
void BuildBlock(int B, int l, int r)
{
pos[B].clear();
for(int i=l;i<=r;i++) st[B].insert({a[i],-i});
}
void BreakBlock(int B)
{
while(st[B].size())
{
int p=-1;
if(pos[B].size()) p=*pos[B].rbegin(),pos[B].erase(--pos[B].end());
while(st[B].size() && -st[B].rbegin()->second>p)
{
a[-st[B].rbegin()->second]=st[B].rbegin()->first;
st[B].erase(--st[B].end());
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... |