Advertisement
a53

CautariLiniare

a53
Jan 19th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. signed main()
  5. {
  6. ios::sync_with_stdio(false);
  7. cin.tie(0);
  8. int n;
  9. cin>>n;
  10. int a[n+1];
  11. for(int i=1;i<=n;++i)
  12. cin>>a[i];
  13. int x,k,p=0,q=0,r=0,K=0;
  14. cin>>x>>k;
  15. bool ok=true;
  16. for(int i=1;i<=n;++i)
  17. {
  18. if(a[i]==x&&ok)
  19. p=i,ok=false;
  20. if(a[i]==x)
  21. {
  22. q=i,++K;
  23. if(k==K)
  24. r=i;
  25. }
  26. }
  27. cout<<p<<'\n'<<q<<'\n'<<r;
  28. return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement