I wanted to do a runtime analysis of B. It got AC even though I doubted it as it looked worst case O(n^2). Basically I just simulated what was asked. It is also mentioned in the editorial that simulation would take too much time. I am now really interested in the runtime of my code.
ARC-105_B
Also any ideas on D?
Edit: For this test case:
1 2 10e9
your code will run $$$10^9$$$ loops. The test cases were so weak. In those test cases there was not any test case where $$$max\space element - min\space element > 10^5$$$ (or something more) appeared.I dont think so..as the size of the hashset remains constant for quite a time before reducing by 1. Also it doesnt explain the statement in the editorial.
Ok. Try this test case:
1 2 10000000
. It executes in around $$$2$$$ seconds for your code. May be the test cases were weak. My solution is also like you which will give TLE in some cases.