Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int n,k,a[1005],i,j,ok=0,poz1,poz2,lung,p1,p2;
  7.  
  8. cin >> n >> k;
  9.  
  10. for(i=1;i<=n;i++){
  11. cin >> a[i];
  12. }
  13.  
  14. for(i=1;i<=n-1;i++){
  15. for(j=i+1;j<=n;j++){
  16. if(a[i]==a[j]){
  17. poz1=i;
  18. poz2=j;
  19. lung=0;
  20. while(a[poz1]==a[poz2] && lung < k){
  21. poz1++;
  22. poz2++;
  23. lung++;
  24. }
  25. if(lung==k){
  26. cout<<poz1-lung<<" "<<poz2-lung;
  27. return 0;
  28.  
  29. }
  30. }
  31. }
  32.  
  33.  
  34. }
  35. cout <<"NU";
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement