自己看
2026-08-18 10:54:07
发布于:广东
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
cin>>n>>k;
vector<ll> a(n,0);
for(ll i=0;i<n;i++) cin>>a[i];
auto ans=upper_bound(a.begin(),a.end(),k);
if(ans==a.begin()){
cout<<-1<<endl;
}else{
cout<<*(ans-1)<<endl;
}
//fclose(stdin);
//fclose(stdout);
return 0;
}
//coder::by::M91
这里空空如也






有帮助,赞一个