| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 127137 | 余冠学 | 折半查找法 | C++ | Wrong Answer | 60 | 1 MS | 288 KB | 407 | 2024-01-25 08:01:22 |
# include <algorithm> # include <iostream> using namespace std; int main(){ int n,m; cin >> n; int a[n]; for (int i = 0;i < n;i++) cin >> a[i]; sort(a,a+n); cin >> m; int l = 0,r = n - 1; while (l < r){ int mid = l + r >> 1; if (a[mid] == m){ cout << mid + 1; return 0; }else if (a[mid] > m){ r = mid - 1; }else{ l = mid + 1; } }cout << -1; return 0; }