C
could.net
I have a class board, like this:
struct board
{
int x1, x2, h;
int time1, time2;
void calculate_time();
void assign(int x1__,int x2__,int h__);
};
And I have n boards stored in an array called boards__[n], and I have
got the array sorted by board.h ascendantly.
I have a pair<int,int> t=pair<int,int>(x0,h0).
What I want to do is: to find the last board int boards__[n] which
satisfies this:
its h< h0,
and its x1<=t.first
and its x2>=t.second.
So, can I do it by upper_bound or lower_bound?
Which one do I have to use?
I tried for a moment and I couldn't find a way. Will you please help me
out?
Thanks!
struct board
{
int x1, x2, h;
int time1, time2;
void calculate_time();
void assign(int x1__,int x2__,int h__);
};
And I have n boards stored in an array called boards__[n], and I have
got the array sorted by board.h ascendantly.
I have a pair<int,int> t=pair<int,int>(x0,h0).
What I want to do is: to find the last board int boards__[n] which
satisfies this:
its h< h0,
and its x1<=t.first
and its x2>=t.second.
So, can I do it by upper_bound or lower_bound?
Which one do I have to use?
I tried for a moment and I couldn't find a way. Will you please help me
out?
Thanks!