#include<bits/stdc++.h>
#include "koninc.h"
using namespace std;
const int MAXN = 300001, rad = 600;
int N, K, v[MAXN+5], done = 200000;
int buk[MAXN+5], L[1012], R[1012], ad[1012], nrbuk, aans[1012];
short ans[502][100012];
void proc(int bk, int LL, int RR)
{
for(int j = L[bk]; j <= R[bk]; ++j)
{
if(v[j] >= K)
ans[bk][0] = 0;
else
if(K - v[j] <= 100000)
ans[bk][K - v[j]] = 0;
}
for(int j = LL; j <= RR; ++j)
v[j]++;
for(int j = L[bk]; j <= R[bk]; ++j)
{
v[j] += ad[bk];
if(v[j] >= K)
ans[bk][0]++;
else
if(K - v[j] <= 100000)
ans[bk][K - v[j]]++;
}
ad[bk] = 0;
aans[bk] = ans[bk][0];
}
void inicjuj(int n, int k, int *D)
{
N = n, K = k;
for(int i = 0; i < n; ++i)
v[i] = D[i];
for(int i = 0; i < n; ++i)
{
if(i % rad == 0)
++nrbuk, L[nrbuk] = i;
R[nrbuk] = i;
buk[i] = nrbuk;
}
for(int i = 0; i <= nrbuk; ++i)
proc(i, 1, 0);
}
void podlej(int a, int b)
{
int fini = R[buk[a]];
int ax = buk[a];
proc(ax, a, min(b, fini));
a = min(b, fini) + 1;
while(a < N && R[buk[a]] <= b)
++ad[buk[a]], aans[buk[a]] = aans[buk[a]] + ans[buk[a]][ad[buk[a]]], a = R[buk[a]] + 1;
if(a <= b)
{
fini = R[buk[a]];
ax = buk[a];
proc(ax, a, b);
}
--done;
}
int dojrzale(int a, int b)
{
int fini = R[buk[a]];
int qans = 0;
proc(buk[a], 1, 0);
while(a <= b && a <= fini)
{
if(v[a] >= K)
++qans;
++a;
}
while(a < N && R[buk[a]] <= b)
qans += aans[buk[a]], a = R[buk[a]] + 1;
if(a <= b)
{
proc(buk[a], 1, 0);
fini = R[buk[a]];
while(a <= b && a <= fini)
{
if(v[a] >= K)
++qans;
++a;
}
}
--done;
return qans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
15 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
554 ms |
1380 KB |
Output is correct |
2 |
Correct |
392 ms |
1024 KB |
Output is correct |
3 |
Correct |
378 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
982 ms |
1580 KB |
Output is correct |
2 |
Correct |
294 ms |
1656 KB |
Output is correct |
3 |
Correct |
357 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1099 ms |
29936 KB |
Output is correct |
2 |
Correct |
1279 ms |
23320 KB |
Output is correct |
3 |
Correct |
669 ms |
2104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2113 ms |
42664 KB |
Output is correct |
2 |
Correct |
1863 ms |
31568 KB |
Output is correct |
3 |
Correct |
961 ms |
8376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2808 ms |
32876 KB |
Output is correct |
2 |
Correct |
1971 ms |
45312 KB |
Output is correct |
3 |
Correct |
1643 ms |
11152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4014 ms |
63316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2941 ms |
10256 KB |
Output is correct |
2 |
Correct |
2045 ms |
9272 KB |
Output is correct |
3 |
Correct |
2846 ms |
16196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2844 ms |
9172 KB |
Output is correct |
2 |
Correct |
3535 ms |
9408 KB |
Output is correct |
3 |
Correct |
2050 ms |
11724 KB |
Output is correct |