#include <iostream>
#include <vector>
#include <algorithm>
using std::cout;
using std::endl;
using std::vector;
int main()
{
vector<int> vec{ 1, 2, 7, 8, 9};
vector<int>::iterator p;
p = upper_bound(vec.begin(), vec.end(), 3);
cout << "position: " << (p - vec.begin()) << " value: " << *p << endl;
return 0;
}
/*
run:
position: 2 value: 7
*/