提交记录 16534


用户 题目 状态 得分 用时 内存 语言 代码长度
shenlc 1003. 测测你的二分查找 Accepted 100 341.27 us 12 KB C++ 298 B
提交时间 评测时间
2021-10-01 16:35:56 2021-10-01 16:35:59
int binary_search(const unsigned *a, int n, unsigned x)
{
	int l = 0, r = n - 1, mid = (l + r) / 2;

    while (l < r - 1) {
        if (x > a[mid]) l = mid;
        else r = mid;
        mid = (l + r) / 2;
    }
    if (x > a[r]) return r + 1;
    else if (x > a[l]) return r;
    else return l;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1341.27 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-19 01:40:16 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠