_Nishat_tasnim

Next Round

Mar 26th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,k;
  7. scanf("%d",&n);
  8. int arr[n];
  9. scanf("%d",&k);
  10. for(int i=1; i<=n; i++)
  11. {
  12. scanf("%d",&arr[i]);
  13. }
  14. if(arr[k]>=k && arr[k+1]>=k)
  15. {
  16. printf("%d\n",k+1);
  17. }
  18. else if(arr[k]>=k && arr[k+1]<k)
  19. {
  20. printf("%d\n",k);
  21. }
  22. else if(arr[k]<k)
  23. {
  24. printf("0\n");
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment