#C11012. Final Task Priority
Final Task Priority
Final Task Priority
You are given several test cases. In each test case, you will receive a list of operations on various tasks. Each operation consists of two integers: a task identifier and a priority change (which can be positive, negative, or zero).
You are also given a specific task identifier for which you need to compute the final priority value. The final priority for a task is computed by the formula:
\( priority = \sum_{i=1}^{n} change_i \)
where each \( change_i \) is the priority change for operations associated with that task. If there is no operation for the given task, the final priority is 0.
Your task is to process all test cases and output the resulting final priority for the queried task in each test case.
inputFormat
The first line contains an integer T
, representing the number of test cases. For each test case, the input is structured as follows:
- The first line of a test case contains two integers
N
andQ
, whereN
is the number of operations andQ
is the task identifier to be queried. - This is followed by
N
lines, each containing two integers: thetask_id
and the correspondingpriority change
.
All input values are provided via standard input (stdin).
outputFormat
For each test case, output one integer on a new line representing the final priority of the queried task. The output should be written to standard output (stdout).
## sample2
3 2
1 10
2 5
1 -5
4 3
1 15
3 7
2 -3
3 2
5
9
</p>