0分求解

4 条评论

  • @ 2026-4-11 20:16:34

    root人真好

    • @ 2026-4-11 20:16:12

      #include<bits/stdc++.h> using namespace std; int n,x,a[200005]; int main(){

      cin>>n>>x; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } int l=0,r=n+1; while(l+1<r) { int xb=(l+r)/2; if(a[xb]<=x) l=xb; else r=xb; } if(a[l]<=x&&l!=0) { cout<<l; } else { cout<<-1; } return 0; }

      • @ 2026-4-9 20:44:55

        Yes,下次可以把代码贴出来,大家能看到,就有更多的机会帮你找到问题

        • @ 2026-4-9 17:54:32

          那你倒是把你的代码发出来撒

          • 1

          信息

          ID
          4949
          时间
          ms
          内存
          MiB
          难度
          3
          标签
          递交数
          49
          已通过
          33
          上传者