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 <vector>
using namespace std;
/*
N knights
C rounds S[i] - E[i]
R-ranked late knight
K = initial ordering of present knights.
*/
const int INF = 1'000'000'000;
struct segtree
{
int l;
int r;
int mn = 0;
int mx = 0;
int lp = 0;
segtree* left = NULL;
segtree* right = NULL;
segtree()
{
;
}
segtree(int L, int R)
{
l = L;
r = R;
if(l == r) return;
int m = (l+r)/2;
left = new segtree(l, m);
right = new segtree(m+1, r);
}
void add(int L, int R, int V)
{
if(R < l || r < L) return;
else if(L <= l && r <= R)
{
lp += V;
mn += V;
mx += V;
}
else
{
left->add(L, R, V);
right->add(L, R, V);
mn = lp + min(left->mn, right->mn);
mx = lp + max(left->mx, right->mx);
}
}
int rangemin(int L, int R)
{
if(R < l || r < L) return INF;
else if(L <= l && r <= R) return mn;
else return lp + min(left->rangemin(L, R), right->rangemin(L, R));
}
int rangemax(int L, int R)
{
if(R < l || r < L) return -1 * INF;
else if(L <= l && r <= R) return mx;
else return lp + max(left->rangemax(L, R), right->rangemax(L, R));
}
};
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E)
{
segtree ST(0, 99'999);
for(int i = 0; i < 100'000 * 20; i++)
ST.add(23, 57878, +4);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |