310602: CF1858B. The Walkway

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. The Walkwaytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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

Petya is standing in the beginning of the Walkway. He will pass near all benches starting from the $1$-st bench and ending with the $n$-th bench. Petya passes the distance between two consecutive benches in $1$ 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 $i$-th ($1 \le i \le n$) bench if and only if at least one of the following conditions holds:

  • There is a cookie seller near the $i$-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 $d$ minutes passed since Petya ate the previous cookie. In other words, Petya has not eaten a cookie near the benches $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.

Input

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

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

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

It is guaranteed that the sum of $m$ over all test cases does not exceed $10^5$.

Output

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.

ExampleInput
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
Output
3 1
4 1
4 4
6 4
5 2
7 7
1 1
51 1
Note

In the first test case $n=6$, $m=2$, $d=2$ and $s=[2, 5]$. If no cookie seller is removed, then Petya will eat $4$ 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 $1$-st bench since he has not yet eaten a cookie.
  • Petya will eat a cookie near the $2$-nd bench since there is a cookie seller near this bench.
  • Petya will not eat a cookie near the $3$-rd bench since only $1<d$ minute passed since he ate a cookie.
  • Petya will eat a cookie near the $4$-th bench since $2\ge d$ minutes passed since he ate a cookie.
  • Petya will eat a cookie near the $5$-th bench since there is a cookie seller near this bench.
  • Petya will not eat a cookie near the $6$-th bench since only $1<d$ minute passed since he ate a cookie.

If the $1$-st cookie seller is removed, Petya will eat $3$ cookies (near the benches $1$, $3$ and $5$). If the $2$-nd cookie seller is removed, Petya will eat $4$ cookies (near the benches $1$, $2$, $4$ and $6$).

Thus, the minimum number of cookies Petya will eat is $3$; 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 $1$-st or the $2$-nd cookie seller results in Petya eating $5$ cookies near the benches $1$, $3$, $5$, $7$, $8$;
  • the removal of the $3$-rd cookie seller results in Petya eating $4$ cookies near the benches $1$, $3$, $5$, $7$.

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 $4$ 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.

Output

题目大意:
在夏日信息学院的主步行道上,有n个长椅,编号为1到n。还有m个卖饼干的人,第i个卖饼干的人位于第s_i个长椅旁。佩特亚从步行道起点开始,依次经过所有长椅。他有一个装有无尽饼干的书包,会在经过长椅时吃饼干,也会从卖饼干的人那里购买饼干。

佩特亚只在长椅旁吃饼干,遵循以下规则:
- 如果长椅旁有卖饼干的人,他会从卖饼干的人那里购买并立即吃掉。
- 如果他还没有吃过饼干,他会从书包里拿一个并立即吃掉。
- 如果从他上次吃饼干到现在至少过了d分钟,他会从书包里拿一个并立即吃掉。

目标是让佩特亚在行走过程中吃的饼干数量最少。为了达到这个目标,你可以要求夏日信息学院的管理人员在佩特亚开始行走前,移除恰好一个卖饼干的人。

输入输出数据格式:
输入:
- 第一行包含一个整数t(1≤t≤10^3),表示测试用例的数量。
- 每个测试用例的第一行包含三个整数n、m和d(2≤d≤n≤10^9,2≤m≤min(10^5, n)),分别表示长椅的数量、卖饼干的人的数量和参数d的值。
- 每个测试用例的第二行包含m个整数s_1, s_2, ..., s_m(1≤s_i≤n),表示卖饼干的人的位置。保证s_i < s_(i+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
```
输出:
```
3 1
4 1
4 4
6 4
5 2
7 7
1 1
51 1
```题目大意: 在夏日信息学院的主步行道上,有n个长椅,编号为1到n。还有m个卖饼干的人,第i个卖饼干的人位于第s_i个长椅旁。佩特亚从步行道起点开始,依次经过所有长椅。他有一个装有无尽饼干的书包,会在经过长椅时吃饼干,也会从卖饼干的人那里购买饼干。 佩特亚只在长椅旁吃饼干,遵循以下规则: - 如果长椅旁有卖饼干的人,他会从卖饼干的人那里购买并立即吃掉。 - 如果他还没有吃过饼干,他会从书包里拿一个并立即吃掉。 - 如果从他上次吃饼干到现在至少过了d分钟,他会从书包里拿一个并立即吃掉。 目标是让佩特亚在行走过程中吃的饼干数量最少。为了达到这个目标,你可以要求夏日信息学院的管理人员在佩特亚开始行走前,移除恰好一个卖饼干的人。 输入输出数据格式: 输入: - 第一行包含一个整数t(1≤t≤10^3),表示测试用例的数量。 - 每个测试用例的第一行包含三个整数n、m和d(2≤d≤n≤10^9,2≤m≤min(10^5, n)),分别表示长椅的数量、卖饼干的人的数量和参数d的值。 - 每个测试用例的第二行包含m个整数s_1, s_2, ..., s_m(1≤s_i≤n),表示卖饼干的人的位置。保证s_i < s_(i+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 ``` 输出: ``` 3 1 4 1 4 4 6 4 5 2 7 7 1 1 51 1 ```

加入题单

上一题 下一题 算法标签: