# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447697 | dutch | Cake 3 (JOI19_cake3) | C++17 | 553 ms | 15048 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;
#define int long long
const int LIM = 2e5, INF = 1e18;
int n, m, L, R, fVal[LIM+1], fCnt[LIM+1], pos[LIM], ans = -INF;
array<int, 2> a[LIM], b[LIM];
void add(int i, int j){
int v = a[i][1] * j; i = pos[i];
for(; i<=n; i+=i&-i){
fCnt[i] += j;
fVal[i] += v;
}
}
int get(int l, int r){
assert(r-l >= m-2);
while(R < r) add(R++, 1);
while(L > l) add(--L, 1);
while(R > r) add(--R,-1);
while(L < l) add(L++,-1);
int v = m - 2, i = 0, s = 0;
for(int j=1<<19; j/=2; ){
if(i+j <= n && fCnt[i+j] <= v){
i += j;
s += fVal[i];
v -= fCnt[i];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |