This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e4 + 10;
int N, L, Q, arr[MX], que[MX], pref[MX], ans[MX][105];
vector<int> sq;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N >> L;
for(int i = 0; i < N; i++) cin >> arr[i];
cin >> Q;
for(int i = 0; i < Q; i++){
cin >> que[i];
sq.push_back(que[i]);
}
sort(sq.begin(), sq.end());
for(int df = 1; df < N - L + 1; df++){
for(int i = 0; i < N - df; i++){
if(arr[i] != arr[i + df]) pref[i + 1] = pref[i] + 1;
else pref[i + 1] = pref[i];
}
for(int i = 0; i < N - L + 1 - df; i++){
int curr = pref[i + L] - pref[i], id = lower_bound(sq.begin(), sq.end(), curr) - sq.begin();
ans[i][id]++;
ans[i + df][id]++;
}
}
for(int i = 0; i < N; i++){
for(int j = 1; j < Q; j++) ans[i][j] += ans[i][j - 1];
}
for(int i = 0; i < Q; i++){
int id = lower_bound(sq.begin(), sq.end(), que[i]) - sq.begin();
for(int k = 0; k < N - L + 1; k++) cout << ans[k][i] << " ";
cout << '\n';
}
}
Compilation message (stderr)
lot.cpp: In function 'int main()':
lot.cpp:40:7: warning: unused variable 'id' [-Wunused-variable]
40 | int id = lower_bound(sq.begin(), sq.end(), que[i]) - sq.begin();
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |