Longest Strike Codeforces Solution | Codeforces Problem Solution 2022
Given an array of length and an integer , you are tasked to find any two numbers and () such that:
- For each , appears in at least times (i.e. or more array elements are equal to ).
- The value is maximized.
If no numbers satisfy the conditions, output -1.
For example, if and , then:
- for , the first condition fails because does not appear at least times.
- for , the first condition holds, because occurs at least times in and occurs at least times in .
- for , the first condition holds, because occurs at least times in .
A pair of and for which the first condition holds and is maximal is , .
The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
Most Similar Words Codeforces Solution
The first line of each test case contains the integers and (, ) — the length of the array and the minimum amount of times each number in the range should appear respectively.
Then a single line follows, containing integers describing the array ().
It is guaranteed that the sum of over all test cases does not exceed .
For each test case output numbers, and that satisfy the conditions, or "-1" if no numbers satisfy the conditions.
If multiple answers exist, you can output any.
Join Now for Solution:-
No comments:
Post a Comment