C. Killjoy SOLUTIONS CODEFORCES

Killjoy SOLUTION

Another operator called Killjoy imagined an infection COVID-2069 that contaminates accounts on Codeforces. Each record has a rating, depicted by a number (it can be negative or extremely enormous). 
 
Downer’s record is now contaminated and has a rating equivalent to x. Its rating is steady. There are n accounts aside from hers, numbered from 1 to n. The I-th record’s underlying rating is ai. Any contaminated record (at first the main tainted record is Killjoy’s) right away taints any uninfected record if their evaluations are equivalent. This can occur toward the start (before any appraising changes) and after each challenge. On the off chance that a record is contaminated, it can not be mended. 
 
Challenges are consistently hung on Codeforces. In each challenge, any of these n accounts (counting tainted ones) can partake. Downer can’t partake. After each challenge appraisals are changed thusly: every member’s evaluating is changed by a whole number, yet the total of all progressions must be equivalent to zero. New evaluations can be any whole number. 
 
Discover the negligible number of challenges expected to taint all records. You can pick which records will partake in each challenge and how the evaluations will change. 
 
It very well may be demonstrated that everything records can be contaminated in some limited number of challenges. 
 
Information 
 
The primary line contains a solitary number t (1≤t≤100) — the quantity of experiments. The following 2t lines contain the portrayals of all experiments. 
 
The principal line of each experiment contains two whole numbers n and x (2≤n≤103, −4000≤x≤4000) — the quantity of records on Codeforces and the rating of Killjoy’s record. 
 
The second line of each experiment contains n whole numbers a1,a2,… ,a (−4000≤ai≤4000) — the appraisals of different records. 
 
Yield 
 
For each experiment yield the negligible number of challenges expected to taint all records. 
 
Model 
 
inputCopy 
 
 
2 69 
 
68 70 
 
6 4 
 
 
9 38 
 
– 21 83 50 – 59 – 77 15 – 71 – 78 20 
 
outputCopy 
 
 
 
 
Note 
 
In the principal experiment it’s conceivable to make all appraisals equivalent to 69. First record’s appraising will increment by 1, and second record’s evaluating will diminish by 1, so the aggregate of all progressions will be equivalent to zero. 
 
In the subsequent experiment all records will be quickly tainted, in light of the fact that all evaluations (counting Killjoy’s record’s appraising) are equivalent to 4.
 

Leave a Comment

close
error: Content is protected !!