Minimum number
Practice
0 (0 votes)
Hiring
Hiring
Hiring
Basic programming
Implementation
Easy
Basics of implementation
Problem
41% Success 41 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array \(A\). You are required to divide this array into exactly \(K\) non-empty segments and check whether the minimum element \(S\) amongst the maximum elements amongst all segments is less than \(Q\) or not.
In other words, if you store the maximum element of each of the segment in an array \(P\), then you must check if the minimum element in \(P\) is less than \(Q\) or not.

Input format

  • First line: \(T\) denoting the number of test cases
  • For each test case:
    • First line: Three integers \(N, K, and\ Q\) denoting the number of elements in the array, number of segments, and arbitrary number respectively
    • Second line: \(N\) space-separated integers, \(A_{1}\), \(A_{2}\), ... \(A_{n}\)

Output format

For each test case, if \(S\) is less than \(Q\), then print \(S\), else print \(NO\). The answer for each test case must be printed in a new line.

Constraints

\( 1 \le T \le 10 \)

\( 1 \le N \le10^{5} \)

\( 1 \le K \le N \)

\( 0 \le Q \le 10^{9} \)

\( 1 \le A_{i} \le 10^{9} \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
1 votes
Tags:
Prime FactorizationVery-EasyVery-Easy
Points:30
26 votes
Tags:
Ad-HocAlgorithmsBrute-force searchDijkstra's algorithmGraphsMediumShortest Path Algorithm簡単-普通
Points:20
4 votes
Tags:
Hash tableHashMapBasic ProgrammingEasyOpenApproved