提交记录 21527


用户 题目 状态 得分 用时 内存 语言 代码长度
liswt 1003. 测测你的二分查找 Accepted 100 503.96 us 12 KB C++17 354 B
提交时间 评测时间
2024-04-12 11:32:31 2024-04-12 11:32:35
int binary_search(const unsigned *a, int n, unsigned x)
{
	static int ans=-1,nx;
	register unsigned l=0,r=n-1,mid;
	if(ans!=-1)
	{
		if(x==nx)return ans;
		if(x<nx)r=ans-1;
		else l=ans+1;
	}
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(a[mid]==x)
		{
			nx=x;
			return ans=mid;
		}
		if(a[mid]<x)
		{
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	return l;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1503.96 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-19 01:40:46 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用