fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. vector<int>v={1,2,2,2,2,3,4,5,6,7};
  5. int num = 2;
  6.  
  7. int main() {
  8. cout<<(lower_bound(v.begin(),v.end(),num)-v.begin() + upper_bound(v.begin(),v.end(),num)-v.begin()-1)/2<<endl;
  9. return 0;
  10. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
2