Logo
(追記) (追記ここまで)

24641번 - Day Streak 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 512 MB3412932.143%

문제

Recently Deltaforces, a famous competitive programming website, added a lot of new visual information to user profiles. In particular, there is a maximum day streak --- the maximum number of days in a row with at least one problem solved. You decided that the maximum day streak in your profile does not accurately represent your training efforts. So you came up with a thought --- what if you could change the time zone in your profile to increase the maximum day streak?

Let's formalize this setting as follows. Suppose you have solved $n$ problems, and the $i$-th problem was solved at time $a_i$. There are $m$ time zones, numbered from 0ドル$ to $m - 1$. The default time zone is 0ドル$. If you decide to change your time zone to $t,ドル all solutions' timestamps increase by $t$: the problem solved at time $a_i$ is now considered to be solved at time $a_i + t,ドル for all $i$ simultaneously.

The problem solved at time $x$ is considered to be solved on day number $\lfloor \frac{x}{m} \rfloor$. Here $\lfloor v \rfloor$ means $v$ rounded down to the greatest integer less than or equal to $v$.

To display the maximum day streak, Deltaforces finds such $l$ and $r$ that you have solved at least one problem on each of days $l, l+1, \ldots, r,ドル and $r - l + 1$ is as large as possible. Then your maximum day streak is shown as $r - l + 1$.

Find the maximum day streak you can achieve by selecting a time zone.

입력

Each test contains multiple test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 2 \cdot 10^5$). Description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ --- the number of solved problems and the number of time zones (1ドル \le n \le 2 \cdot 10^5$; 1ドル \le m \le 10^9$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ --- distinct timestamps of your solutions, in chronological order (0ドル \le a_1 < a_2 < \dotsb < a_n \le 10^9$).

It is guaranteed that the sum of $n$ over all test cases does not exceed 2ドル \cdot 10^5$.

출력

For each test case, print two integers $s$ and $t$ --- the maximum day streak and any time zone that achieves it (1ドル \le s \le n$; 0ドル \le t < m$).

제한

예제 입력 1

5
4 10
0 3 8 24
2 10
32 35
10 1
0 1 3 4 5 6 7 10 11 12
10 24
0 1 3 4 5 6 7 10 11 12
8 24
26 71 101 147 181 201 244 268

예제 출력 1

3 2
2 5
5 0
2 12
4 15

힌트

In the first example test case, when you select time zone 2ドル,ドル the timestamps of your solutions change to 2ドル,ドル 5ドル,ドル 10ドル,ドル and 26ドル$. It means the problems are now considered to be solved on days 0ドル,ドル 0ドル,ドル 1ドル,ドル and 2ドル$; that is a 3ドル$-day streak. Time zones 3ドル,ドル 4ドル,ドル and 5ドル$ yield the same answer.

In the second example test case, timestamps of your solutions are 37ドル$ and 40ドル$ in time zone 5ドル,ドル which corresponds to days 3ドル$ and 4ドル$. Time zones 6ドル$ and 7ドル$ also work.

In the third example test case, only one time zone exists, and your maximum day streak is 5ドル$.

In the fourth example test case, you have solved many problems but in a short period of time, and you can't obtain more than a 2ドル$-day streak.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2021-2022 North-Western Russia Regional Contest D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /