Connection Status:
Competition Arena > TheBoredomDivTwo
SRM 488 · 2010-03-12 · by Vasyl[alphacom] · Simple Search, Iteration
Class Name: TheBoredomDivTwo
Return Type: int
Method Name: find
Arg Types: (int, int, int, int)
Problem Statement

Problem Statement

John and Brus are bored. They have n+m common friends. The first n of them are bored and other m are not. John chooses the j-th (1-based) friend for a talk. If the friend is not bored, he becomes bored after the talk. Brus does the same with the b-th (1-based) friend. Note that John and Brus can't choose the same friend.

You have to find the number of bored friends after the talks.

Constraints

  • n will be between 1 and 47, inclusive.
  • m will be between 1 and 47, inclusive.
  • j will be between 1 and n+m, inclusive.
  • b will be between 1 and n+m, inclusive.
  • j and b will be different.
Examples
0)
1
1
1
2
Returns: 2

The first friend is already bored and the second friend becomes bored after the talk with Brus.

1)
2
1
1
2
Returns: 2

Here John and Brus choose two friends that are already bored.

2)
1
2
3
2
Returns: 3

All the friends become bored.

3)
4
7
7
4
Returns: 5
4)
9
9
18
13
Returns: 11

Submissions are judged against all 67 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class TheBoredomDivTwo with a public method int find(int n, int m, int j, int b) · 67 test cases · 2 s / 256 MB per case

Submitting as anonymous