fork download
  1. #include<iostream>
  2. #include<bits/stdc++.h>
  3. #define ll long long
  4. const int ii=123456789;
  5. using namespace std;
  6.  
  7. int main(){
  8. int n,k,b;cin>>n>>k>>b;
  9. int x[100001]={};
  10. for(int i=0;i<b;i++){
  11. int p;cin>>p;
  12. x[p]=1;
  13. }
  14. int d=0,s=ii;
  15. for(int i=1;i<=k;i++){
  16. if(x[i]==1) d++;
  17. }
  18. for(int i=k+1;i<n;i++){
  19. d=d+x[i]-x[i-k];
  20. s=min(s,d);
  21. }
  22. cout<<s;
  23. }
Success #stdin #stdout 0.01s 5472KB
stdin
10 6 5
2
10
1
5
9
stdout
1