Number of arrays

2.2

48 votes
Basic Programming, Basics of Implementation, Easy, Hiring, Implementation
Problem

You are given an array A. You need 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 we store the maximum element of each of the segment in an array P, then you have to check if minimum element in P is less than Q or not.

Input:

  • First line of input contains number of testcases, T
  • First line of each testcase contains three integers: N denoting number of elements in array A, K denoting number of segments and Q.
  • Second line of each testcase contains N space-separated integers, A1 , A2, ... An.

Output:

  • For each testcase, if S is less than Q, print S, else print "NO" (without quotes).
  • Answer for each test case should come in a new line.

Constraints:

  • 1T10
  • 1N105
  • 1KN
  • 0Q109
  • 1Ai109
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

We can divide the complete array into 5 segments ---1, 2, 3, 4, 5. The minimum number among this number is 1 which is less than 2.

Editor Image

?