#include <bits/stdc++.h>
using
namespace
std;
void
findLowerBound(
list<pair<
int
,
int
> >& list,
pair<
int
,
int
>& p)
{
auto
low = lower_bound(list.begin(),
list.end(), p);
cout <<
"lower_bound() for {2, 5}"
<<
" is at index: {"
<< (*low).first <<
", "
<< (*low).second <<
" }"
<< endl;
}
void
findUpperBound(
list<pair<
int
,
int
> >& list,
pair<
int
,
int
>& p)
{
auto
up = upper_bound(list.begin(),
list.end(), p);
cout <<
"upper_bound() for {2, 5}"
<<
" is at index: {"
<< (*up).first <<
", "
<< (*up).second <<
" }"
<< endl;
}
int
main()
{
list<pair<
int
,
int
> > list;
list.push_back(make_pair(1, 3));
list.push_back(make_pair(1, 7));
list.push_back(make_pair(2, 4));
list.push_back(make_pair(2, 5));
list.push_back(make_pair(3, 8));
list.push_back(make_pair(8, 6));
pair<
int
,
int
> p = { 2, 5 };
findLowerBound(list, p);
findUpperBound(list, p);
return
0;
}