#194. AC自动机?自动AC机!
AC自动机?自动AC机!
Description
传说中的自动AC机,搜索并读取答案文件作为输出 ( !!!不要尝试使用它 !!!)
The "automatic AC machine" works as follows: first it will figure out the solution the moment it gets the problem, and then start writing the program. Every second, the "automatic AC machine" may have the following two actions:
-
Write lines of code;
-
Feel unhappy, delete lines of code. If is greater than the length of the code currently written, delete all.
There is a strange OJ, and this OJ has a fixed length , once the "automatic AC machine" accumulates more than lines of code at the end of a second, it will submit his code automatically and get "Accepted", then clear the previous code and start solve the next question . CTR ran the "automatic AC machine" on this OJ for a whole day, and got a lot of log. He suddenly realized that he hadn't recorded the value of for this OJ. But fortunately, the OJ recorded the total number of Accepted solution is m. I hope you can calculate the minimum and maximum possible values of .
Input Format
The first line contains two integer r, m, denoting that the machine produced a total of r lines of log, passed m questions in total.
The second line contains r integers . (), denoting that wrote lines of code, means deleting lines of code.
$r \leq 100000, m \leq 10000, -10^9 \leq k_i \leq 10^9$.
Output Format
Print two numbers and , representing the minimum and maximum possible values of n, respectively. If there is no such n, then output -1.
4 2
2
5
-3
9
3 7