#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[1000100]; int search(int left,int right,int v) { int mid=(left+right)/2; if(left>right) return -1; if(a[mid]==v) return mid; else if(a[mid]<v) return search(mid+1,right,v); else return search(left,mid-1,v); } int main() { int num,l; cin>>num>>l; for(int i=1;i<=num;i++) cin>>a[i]; sort(a+1,a+num+1); cout<<search(0,num,l)<<endl; return 0; }
时间: 2024-11-13 08:07:19