## TopCoder SRM 488 The BoredomDivTwo Published on: 21 Nov 2010

• Used As: Division II Level One

## Solution :

This is a soft ball for those who are in awe of TopCoder. The only thing to this problem is wrapping your head around the fact that it is in fact so simple! All you need to decide is whether the jth and bth person were bored or not. If they were not bored we add one to the bored count. So without too much commentary here is the code

class TheBoredomDivTwo {
public:
int find(int n, int m, int j, int b);
};

int TheBoredomDivTwo::find(int n, int m,int j, int b){
int bored = n;
if( j > n ) bored++;
if( b > n) bored++;
return bored;
}


c++

Just to make the solution a little more interesting you could also do this as a one liner!

class TheBoredomDivTwo {
public:
int find(int n, int m, int j, int b){
return n + (j > n ) + (b > n) ;
}
};


c++

This problem should convince you that you should give TopCoder a try as well.