🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"BUS","problem_name":"Bus full of passengers","problemComponents":{"constraints":"- $1 \\leq T \\leq 20$\n- $1 \\leq N \\leq 10^4$\n- $1 \\leq M \\leq 10^4$\n- $1 \\leq Q \\leq 10^4$","constraintsState":true,"subtasks":"","subtasksState":false,"inputFormat":"- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- Each test case contains $Q + 1$ lines of input.\n- The first line of each test case contains three space-separated integers $N, M, Q$.\n- $Q$ lines follow. For each valid $j$, $j^{th}$ of these lines contains a character $ch$, followed by a space and an integer $i$. Here $ch$ is either \u0027$+$\u0027 or \u0027$-$\u0027 and $1 \\leq i \\leq N$.\n- It is guaranteed that $``+$ $i\u0022$ and $``-$ $i\u0022$ appears at most once for every $1 \\leq i \\leq N$","inputFormatState":true,"outputFormat":"For each test case, print a single line containing one string - \u0022Consistent\u0022 (without quotes) if the sequence is consistent, \u0022Inconsistent\u0022 (without quotes) otherwise.\n","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"2\n2 1 4\n+ 1\n+ 2\n- 1\n- 2\n3 2 6\n+ 2\n+ 1\n- 1\n+ 3\n- 3\n- 2","output":"Inconsistent\nConsistent","explanation":"- **Test case $1$:** After Person $2$ enters the bus, there are two people inside the bus while the capacity of the bus is $1$.","isDeleted":false},"1":{"id":2,"input":"2\n100 10 5\n+ 1\n+ 2\n- 3\n+ 3\n- 2\n6 4 4\n+ 3\n+ 2\n+ 1\n+ 4\n","output":"Inconsistent\nConsistent\n","explanation":"- **Test case $1$:** Person $3$ leaves the bus without entering and thus it is inconsistent.","isDeleted":false}}},"video_editorial_url":"https://youtu.be/sUd4zQEqjXE","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"utkarsh_adm","problem_tester":"","date_added":"13-08-2021","tags":{"0":"cakewalk","1":"start9","2":"utkarsh_adm"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/BUS","time":{"view_start_date":1629221400,"submit_start_date":1629221400,"visible_start_date":1629221400,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=BUS","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
### Read problem statements in [Mandarin Chinese](https://www.codechef.com/download/translated/START9/mandarin/BUS.pdf) and [Bengali](https://www.codechef.com/download/translated/START9/bengali/BUS.pdf).

There is an **empty bus** with $M$ seats and a total of $N$ people, numbered from $1$ to $N$. Everyone is currently outside the bus. You are given a sequence of $Q$ events of the following form.

 - $+\ i$ :  It denotes that the person $i$ enters the bus.

 - $-\ i$ : It denotes that the person $i$ leaves the bus.

It is guaranteed in the input that each person from $1$ to $N$ 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 exceed $M$ at any point of time).
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>