#P17887. Rain after Summer
Rain after Summer
Background
[NOIP 2018 Junior] Shuttle Bus (Enhanced Version)
Problem Description
Given a non-decreasing sequence of positive integers of length , and an integer .
An integer sequence is defined to be good if and only if it satisfies the following conditions:
- For all , ;
- Sort the sequence in ascending order and denote the result by ; then for all , either or .
Find the minimum value of over all good sequences .
Input Format
This problem contains multiple test cases.
The first line of the input contains an integer , the number of test cases.
Then test cases follow. For each test case:
- The first line contains two positive integers .
- The second line contains non-decreasing integers .
Output Format
For each test case, output one line containing a single non-negative integer, the minimum value of over all good sequences .
2
10 7
12 18 23 24 29 40 41 45 50 60
3 99
1 1 1
357
3
Hint
【Constraints】
This problem uses bundled testing.
- Subtask 1 (10 pts): .
- Subtask 2 (25 pts): .
- Subtask 3 (20 pts): .
- Subtask 4 (20 pts): .
- Subtask 5 (25 pts): .
For all testdata, it is guaranteed that , and the sequence is non-decreasing.
Translated by QwenWork