Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n,k,a[1005],i,j,ok=0,poz1,poz2,lung,p1,p2;
- cin >> n >> k;
- for(i=1;i<=n;i++){
- cin >> a[i];
- }
- for(i=1;i<=n-1;i++){
- for(j=i+1;j<=n;j++){
- if(a[i]==a[j]){
- poz1=i;
- poz2=j;
- lung=0;
- while(a[poz1]==a[poz2] && lung < k){
- poz1++;
- poz2++;
- lung++;
- }
- if(lung==k){
- cout<<poz1-lung<<" "<<poz2-lung;
- return 0;
- }
- }
- }
- }
- cout <<"NU";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement