Bus full of passengers solution codechef
There is an empty bus withseats and a total of people, numbered from to . Everyone is currently outside the bus. You are given a sequence of events of the following form.
: It denotes that the person enters the bus.
: It denotes that the person leaves the bus.
It is guaranteed in the input that each person fromto enters at most once as well as leaves the bus at most once.
Determine whether the sequence of events is consistent or not (i.e. no person leaves the bus before entering and the number of passengers in the bus does not exceedat any point of time).
Input Format Bus full of passengers solution codechef
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- Each test case contains lines of input.
- The first line of each test case contains three space-separated integers .
- lines follow. For each valid , of these lines contains a character , followed by a space and an integer . Here is either ‘ ‘ or ‘ ‘ and .
- It is guaranteed that and appears at most once for every
Output Format Bus full of passengers solution codechef
For each test case, print a single line containing one string – “Consistent” (without quotes) if the sequence is consistent, “Inconsistent” (without quotes) otherwise.
Sample Input 1
2 2 1 4 + 1 + 2 - 1 - 2 3 2 6 + 2 + 1 - 1 + 3 - 3 - 2
Sample Output 1 Bus full of passengers solution codechef
- Test case : After Person enters the bus, there are two people inside the bus while the capacity of the bus is .
Sample Input 2
2 100 10 5 + 1 + 2 - 3 + 3 - 2 6 4 4 + 3 + 2 + 1 + 4
Sample Output 2
- Test case : Person leaves the bus without entering and thus it is inconsistent.