CF1858B.The Walkway

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn benches near the Main Walkway in Summer Infomatics School. These benches are numbered by integers from 11 to nn in order they follow. Also there are mm cookie sellers near the Walkway. The ii -th ( 1im1 \le i \le m ) cookie sellers is located near the sis_i -th bench.

Petya is standing in the beginning of the Walkway. He will pass near all benches starting from the 11 -st bench and ending with the nn -th bench. Petya passes the distance between two consecutive benches in 11 minute. He has a knapsack with an infinite amount of cookies. Petya is going to eat cookies from his knapsack and buy them from cookie sellers during the walk.

Petya eats cookies only near the benches according to the following rule: he will eat the cookie near the ii -th ( 1in1 \le i \le n ) bench if and only if at least one of the following conditions holds:

  • There is a cookie seller near the ii -th bench. Then Petya will buy a cookie from cookie seller and eat it immediately.
  • Petya has not yet eaten a cookie. Then Petya will take a cookie from his knapsack and eat it immediately.
  • At least dd minutes passed since Petya ate the previous cookie. In other words, Petya has not eaten a cookie near the benches i1,i2,,max(id+1,1)i-1, i-2, \ldots, \max(i-d+1, 1) . Then Petya will take a cookie from his knapsack and eat it immediately.

You may assume that Petya eats cookies instantly. Petya will not eat two or more cookies near the same bench.

You want to minimize the number of cookies Petya will eat during his walk. In order to do this, you will ask the administration of the Summer Informatics School to remove exactly one cookie seller from the Walkway before Petya starts his walk.

Please determine the minimum possible number of cookies Petya can eat after removing exactly one cookie seller. Also determine the number of cookie sellers, such that if you remove one of them, Petya will eat the minimum possible number of cookies.

输入格式

The first line contains a single integer tt ( 1t1031 \le t \le 10^3 ) — the number of test cases.

The first line of each test case contains three integers nn , mm and dd ( 2dn1092 \le d \le n \le 10^9 , 2mmin(105,n)2 \le m \le \min(10^{5}, n) ) — the number of benches, the number of cookie sellers and the value of parameter dd from the statement, respectively.

The second line of each test case contains mm integers s1,s2,,sms_1, s_2, \ldots, s_m ( 1sin1 \le s_i \le n ) — the locations of the cookie sellers. It is guaranteed that si<si+1s_{i} < s_{i+1} for all 1im11 \leq i \leq m - 1 .

It is guaranteed that the sum of mm over all test cases does not exceed 10510^5 .

输出格式

For each test case print two integers — the minimum number of cookies that Petya can eat if exactly one cookie seller is removed, and the number of cookie sellers such that if one of them is removed, Petya will eat the minimum possible number of cookies.

输入输出样例

  • 输入#1

    8
    6 2 2
    2 5
    8 3 2
    3 5 8
    10 4 9
    2 8 9 10
    30 5 8
    6 8 15 24 29
    30 5 8
    6 8 12 20 27
    8 8 3
    1 2 3 4 5 6 7 8
    2 2 2
    1 2
    1000000000 3 20000000
    57008429 66778899 837653445

    输出#1

    3 1
    4 1
    4 4
    6 4
    5 2
    7 7
    1 1
    51 1

说明/提示

In the first test case n=6n=6 , m=2m=2 , d=2d=2 and s=[2,5]s=[2, 5] . If no cookie seller is removed, then Petya will eat 44 cookies during his walk (note that you have to remove exactly one cookie seller; this case is explained only to show how Petya decides whether to eat a cookie):

  • Petya will eat a cookie near the 11 -st bench since he has not yet eaten a cookie.
  • Petya will eat a cookie near the 22 -nd bench since there is a cookie seller near this bench.
  • Petya will not eat a cookie near the 33 -rd bench since only 1<d1<d minute passed since he ate a cookie.
  • Petya will eat a cookie near the 44 -th bench since 2d2\ge d minutes passed since he ate a cookie.
  • Petya will eat a cookie near the 55 -th bench since there is a cookie seller near this bench.
  • Petya will not eat a cookie near the 66 -th bench since only 1<d1<d minute passed since he ate a cookie.

If the 11 -st cookie seller is removed, Petya will eat 33 cookies (near the benches 11 , 33 and 55 ). If the 22 -nd cookie seller is removed, Petya will eat 44 cookies (near the benches 11 , 22 , 44 and 66 ).

Thus, the minimum number of cookies Petya will eat is 33 ; there is only one cookie seller such that removing it results in minimizing the number of cookies Petya will eat.

In the second test case

  • the removal of the 11 -st or the 22 -nd cookie seller results in Petya eating 55 cookies near the benches 11 , 33 , 55 , 77 , 88 ;
  • the removal of the 33 -rd cookie seller results in Petya eating 44 cookies near the benches 11 , 33 , 55 , 77 .

Note that the second integer you should output is the number of (that is, amount) cookie sellers, not the index of a cookie seller to remove. Thus, the answer to the second test case is 4 1 because there is only one cookie seller such that removing it results in Petya eating four cookies, which is the minimum possible.

In the third test case Petya will eat 44 cookies no matter what cookie seller is removed.

Note that Petya is not interested in minimizing the number of cookies he will eat, so he eats cookies whenever it is possible under the rule from the statement.

首页