#include<bits/stdc++.h>
#include "koninc.h"
using namespace std;
const int MAXN = 300001, rad = 550;
int N, K, v[MAXN+5];
int buk[MAXN+5], L[1012], R[1012], ad[1012], nrbuk, aans[1012];
int srt[1012][1012];
int ans[1012][300012];
int solve(int bk)
{
if(srt[bk][R[bk] - L[bk]] + ad[bk] < K)
return 0;
int st = 0;
int dr = R[bk] - L[bk];
int ans = dr;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(srt[bk][mid] + ad[bk] >= K)
ans = mid, dr = mid - 1;
else
st = mid + 1;
}
return (R[bk] - L[bk]) - ans + 1;
}
void proc(int bk)
{
for(int j = L[bk]; j <= R[bk]; ++j)
{
if(v[j] >= K)
ans[bk][0] = 0;
else
if(K - v[j] <= 300000)
ans[bk][K - v[j]] = 0;
}
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] <= 300000)
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);
}
void podlej(int a, int b)
{
int fini = R[buk[a]];
while(a <= b && a <= fini)
{
++v[a];
++a;
}
proc(buk[a]);
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]];
while(a <= b && a <= fini)
{
++v[a];
++a;
}
proc(buk[a]);
}
}
int dojrzale(int a, int b)
{
int fini = R[buk[a]];
int qans = 0;
// cout << a << " " << fini << '\n';
proc(buk[a]);
while(a <= b && a <= fini)
{
if(v[a] >= K)
++qans;
++a;
}
// cout << "RC " << a << " " << ans << '\n';
while(a < N && R[buk[a]] <= b)
qans += aans[buk[a]], a = R[buk[a]] + 1;
// cout << "RC " << a << " " << ans << '\n';
if(a <= b)
{
proc(buk[a]);
fini = R[buk[a]];
while(a <= b && a <= fini)
{
if(v[a] >= K)
++qans;
++a;
}
}
return qans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 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 |
7 ms |
376 KB |
Output is correct |
2 |
Correct |
13 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
527 ms |
1508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
939 ms |
2168 KB |
Output is correct |
2 |
Correct |
283 ms |
3292 KB |
Output is correct |
3 |
Correct |
331 ms |
1576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
348 ms |
131076 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
150 ms |
131076 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1557 ms |
131076 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
485 ms |
131076 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2877 ms |
26948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2709 ms |
26308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |