Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
- #define fi first
- #define se second
- #define pb push_back
- #define eb emplace_back
- vector<ll>v;
- ll lower(ll key)
- {
- ll pos;
- ll s=0;
- ll e=v.size()-1;
- ll mid=(s+e)/2;
- while(s<=e)
- { mid=(s+e)/2;
- // cout<<mid<<endl;
- // cout<<s<<" "<<e<<endl; the way ;;
- if(v[mid]>=key)
- {
- e=mid-1;
- pos=mid;
- }
- else
- {
- s=mid+1;
- }
- }
- return pos;
- }
- #define eb emplace_back
- int main()
- {
- fastread();
- ll n;
- cin>>n;
- for(ll i=0;i<n;i++)
- {
- ll a;
- cin>>a;
- v.pb(a);
- }
- sort(v.begin(),v.end());
- ll key;
- cin>>key;
- ll pos=lower(key);
- cout<<pos<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement