#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]].find(ad[buk[a]]) != ans[buk[a]].end())
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 |
28 ms |
376 KB |
Output is correct |
2 |
Correct |
117 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1055 ms |
1228 KB |
Output is correct |
2 |
Correct |
1012 ms |
844 KB |
Output is correct |
3 |
Correct |
1268 ms |
1120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1249 ms |
1236 KB |
Output is correct |
2 |
Correct |
276 ms |
1016 KB |
Output is correct |
3 |
Correct |
1606 ms |
1320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3204 ms |
3212 KB |
Output is correct |
2 |
Execution timed out |
4008 ms |
2720 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4045 ms |
3836 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4100 ms |
2832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4101 ms |
3860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3295 ms |
5456 KB |
Output is correct |
2 |
Correct |
2071 ms |
5688 KB |
Output is correct |
3 |
Execution timed out |
4030 ms |
5412 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3110 ms |
5568 KB |
Output is correct |
2 |
Correct |
3910 ms |
6152 KB |
Output is correct |
3 |
Execution timed out |
4088 ms |
4376 KB |
Time limit exceeded |