# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977859 | vjudge1 | Cake 3 (JOI19_cake3) | C11 | 464 ms | 6740 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<stdio.h>
#include<time.h>
#include<stdlib.h>
#define N 200000
int n, M, v[N],c[N],o[N],v2[N],vm[N],fw[N];
long long fw2[N],z=-1e18;
void add_(int p,int k1,long long k2) { for(;p<N;p|=p+1)fw[p]+=k1,fw2[p]+=k2; }
long long search()
{
long long val2=0;int val=0,pos=0;
for(int j=1<<20;j>>=1;)
if(pos+j<=N&&val+fw[pos+j-1]<=M)pos+=j,val+=fw[pos-1],val2+=fw2[pos-1];
return val2;
}
int cl=0,cr=-1;
void add(int i) { add_(vm[i],1,v[i]); }
void del(int i) { add_(vm[i],-1,-v[i]); }
void move(int l,int r)
{
while(cr<r)add(++cr);
while(cl>l)add(--cl);
while(cr>r)del(cr--);
while(cl<l)del(cl++);
}
void map(int i)
{
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... |