#include<bits/stdc++.h>
#include "koninc.h"
using namespace std;
const int MAXN = 300001, rad = 550;
int N, K, v[MAXN+5], done = 300000;
int buk[MAXN+5], L[1012], R[1012], ad[1012], nrbuk, aans[1012];
unordered_map<int, int> ans[602];
void proc(int bk, int LL, int RR)
{
ans[bk].clear();
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] <= done)
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]];
if(ans[buk[a]].count(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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
456 KB |
Output is correct |
2 |
Correct |
116 ms |
476 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1066 ms |
1200 KB |
Output is correct |
2 |
Correct |
1016 ms |
1016 KB |
Output is correct |
3 |
Correct |
1267 ms |
1068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1212 ms |
1304 KB |
Output is correct |
2 |
Correct |
278 ms |
1016 KB |
Output is correct |
3 |
Correct |
1603 ms |
1248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3149 ms |
3136 KB |
Output is correct |
2 |
Execution timed out |
4006 ms |
2936 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4011 ms |
3664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4070 ms |
2996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4006 ms |
4252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3305 ms |
5568 KB |
Output is correct |
2 |
Correct |
2166 ms |
16244 KB |
Output is correct |
3 |
Execution timed out |
4014 ms |
11796 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3174 ms |
5500 KB |
Output is correct |
2 |
Correct |
3885 ms |
17716 KB |
Output is correct |
3 |
Execution timed out |
4027 ms |
11324 KB |
Time limit exceeded |