Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,k;
- scanf("%d",&n);
- int arr[n];
- scanf("%d",&k);
- for(int i=1; i<=n; i++)
- {
- scanf("%d",&arr[i]);
- }
- if(arr[k]>=k && arr[k+1]>=k)
- {
- printf("%d\n",k+1);
- }
- else if(arr[k]>=k && arr[k+1]<k)
- {
- printf("%d\n",k);
- }
- else if(arr[k]<k)
- {
- printf("0\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment