| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 74137 | 李言 | 二分查找 | C++ | Accepted | 100 | 19 MS | 640 KB | 309 | 2023-05-20 17:16:14 |
#include<bits/stdc++.h> using namespace std; int n,a[114514],k; int main(){ cin>>n; int l=1,r=n; for(int i=1;i<=n;i++) cin>>a[i]; cin>>k; while(l<=r){ int mid=(l+r)/2; if(a[mid]==k){ cout<<mid; return 0; } if(k>a[mid]) l=mid+1; else r=mid-1; } cout<<-1; return 0; }