acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 题解速递

    #include<bits/stdc++.h> using namespace std; int main() { int n,k,m; bool f=false; cin>>n>>k; m=0; vector<int>a(n); for(int i=0;i<n;i++) { cin>>a[i]; } int L=0,R=n-1,M; while(L<=R) { M=L+(R-L)/2; if(a[M]<=k) { f=true; m=max(a[M],m); L=M+1; } else R=M-1; } if(f==true) { cout<<m; } else { cout<<"-1"; } }

    userId_undefined

    走❎本尊

    出道萌新倔强青铜字符串·魔法使循环·循环打卡人分支·分支解题者递归·套娃学徒
    20阅读
    2回复
    3点赞
  • tj

    userId_undefined

    无敌的鳖佬仔给老爷爷猜猜被

    7月全勤卷王时间刺客空间掌握者循环·循环打卡人荣耀黄金I/O·IO入门者
    14阅读
    0回复
    0点赞
  • 题解

    userId_undefined

    zsy

    7月全勤卷王出道萌新题解仙人时间刺客时空双修者秩序白银
    10阅读
    0回复
    0点赞
  • tijie

    #include<bits/stdc++.h> using namespace std; int main(){ int n,m;cin>>n>>m; int a[1031029]; for(int i=1;i<=n;i++){ cin>>a[i]; }int c=-1; int l=1,r=n,mid; while(l<=r){ mid=(l+r)/2; if(a[mid]<=m){ c=a[mid]; l=mid+1; }else{ r=mid-1; } }cout<<c<<"\n"; return 0; }

    userId_undefined

    Null

    出道萌新I/O·IO入门者分支·分支解题者倔强青铜字符串·魔法使
    4阅读
    0回复
    0点赞
  • py

    n,k=list(map(int,input().split())) a=list(map(int,input().split())) a.insert(0,0) l=1 r=n m=0 ans=0 while l<=r: if a[1]>k: ans=-1 break m=(l+r)//2 if a[m]>k: r=m-1 if a[m]<=k: l=m+1 ans=a[m] print(ans)

    userId_undefined

    倪琳

    1阅读
    0回复
    0点赞
首页