fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. vector<int> v = {0,0,1,1,1,1,1,4,5};
  8. auto it = upper_bound(v.begin(), v.end(), 1);
  9. std::cout << std::distance( std::begin(v), it ) << std::endl;
  10. return 0;
  11. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
7