#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,l;
int q,k;
cin >> n >> l;
int tab[n];
//int odp[(n-l+1)];
for (int i=0; i<n; i++){
cin >> tab[i];
}
cin >> q;
cin >> k;
map<pair<int,int>,vector<int>> mapa;
for (int i=0; i<(n-l+1); i++){
for (int j=0; j<l; j++){
if (mapa.find({j,tab[i+j]}) != mapa.end()){
mapa[{j,tab[i+j]}].push_back(i);
}
else{
mapa[{j,tab[i+j]}] = {i};
}
}
}
//for (auto i : tab) cout << i << " ";cout << endl;
for (int i=0; i<(n-l+1); i++){
int wyniki_2[n];
for (int s=0; s<n; s++) wyniki_2[s] = 0;
for (int j=i; j<(i+l); j++){
//cout << i << " " << j << " " << tab[j] << endl;
for (int s : mapa[{j-i,tab[j]}]){
if (i==s) continue;
//cout << i << " " << " " << tab[j] << " " << s << endl;
wyniki_2[s]++;
}
}
vector<int> wyniki(0);
for (int s=0; s<(n-l+1); s++){
if (i==s) continue;
//cout << s << ": " << wyniki_2[s] << " ";
wyniki.push_back(wyniki_2[s]);
}
//cout << endl;
sort(wyniki.begin(),wyniki.end());
//for (auto x : wyniki) cout << x << " ";cout << endl;
int ile=(n-l);
int wsk=0;
while (wsk < (n-l) && (l-wyniki[wsk])>k) { ile--; wsk++; }
//cout << i << " " << wsk << " " << wyniki[wsk] << " " << l-wyniki[wsk] << " " << k << endl;
cout << ile << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1942 ms |
856 KB |
Output is correct |
2 |
Correct |
2237 ms |
1104 KB |
Output is correct |
3 |
Correct |
1554 ms |
856 KB |
Output is correct |
4 |
Correct |
2234 ms |
15968 KB |
Output is correct |
5 |
Runtime error |
1037 ms |
65536 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1942 ms |
856 KB |
Output is correct |
2 |
Correct |
2237 ms |
1104 KB |
Output is correct |
3 |
Correct |
1554 ms |
856 KB |
Output is correct |
4 |
Correct |
2234 ms |
15968 KB |
Output is correct |
5 |
Runtime error |
1037 ms |
65536 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |