#include <bits/stdc++.h>
using namespace std;
int a[10005], s[10005], lb[10005], ans[105][10005], res[105][10005];
pair<int, int> k[10005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, l, q;
cin >> n >> l;
for (int i=1; i<=n; i++)
cin >> a[i];
cin >> q;
for (int i=1; i<=q; i++)
{
cin >> k[i].first;
k[i].second=i;
}
sort(k+1, k+q+1);
for (int i=1; i<=q; i++)
if (!lb[k[i].first])
lb[k[i].first]=i;
lb[l+1]=1e9;
for (int i=l; i>=0; i--)
if (!lb[i])
lb[i]=lb[i+1];
for (int i=1; i<n-l+1; i++)
{
for (int j=1; j<=n-l+1-i; j++)
s[j]=0;
for (int u=1, v=i+1; v<=n; u++, v++)
if (a[u]-a[v])
s[max(1, u-l+1)]++, s[min(n-l+2-i, u+1)]--;
for (int j=1; j<=n-l+1-i; j++)
{
s[j]+=s[j-1];
ans[lb[s[j]]][j]++;
ans[lb[s[j]]][j+i]++;
}
}
for (int i=1; i<=n-l+1; i++)
for (int j=2; j<=q; j++)
ans[j][i]+=ans[j-1][i];
for (int i=1; i<=q; i++)
for (int j=1; j<=n-l+1; j++)
res[k[i].second][j]=ans[lb[k[i].first]][j];
for (int i=1; i<=q; i++)
{
for (int j=1; j<=n-l+1; j++)
cout << res[i][j] << ' ';
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |