提交记录 20712


用户 题目 状态 得分 用时 内存 语言 代码长度
TSKY 1003. 测测你的二分查找 Accepted 100 328.17 us 20 KB C++14 489 B
提交时间 评测时间
2023-12-04 22:28:52 2023-12-04 22:28:56
int binary_search(const unsigned *a, int n, unsigned x)
{
    static int lastid = 0;
    static int last = a[0];
    int l = -1, r = n;
    if (last > x)
    {
        r = lastid;
    }
    else if (last < x)
    {
        l = lastid;
    }
    else
    {
        return lastid;
    }

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

CompilationN/AN/ACompile OKScore: N/A

Testcase #1328.17 us20 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2025-05-09 11:14:59 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠