MIN MAX FACTOR

0

0 votes
Problem

You are given an array consisting of n integers. You have to find the minimum of all the numbers obtained by performing the given operation in all the subarrays of size k.

Given operation : It returns the number in the sub array which has the highest number of prime factors and ties are resolved in favour of large numbers.

 

Input Format

First line contains two integers n and k.

Second line contains n integers (a1, a2, a3, . . .  ,an)  denoting the elements of the array.

 

Output Format

Print a single integer – the minimum of the numbers obtained after 

performing operations in all subarrays of size k.

 

Constraints

1 <= n <= 10^5 

1 <= k <= 10^5 

1 <= a[i] <= 10^5

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For subarray[1-3] 12

For subarray[2-4] 12

For subarray[3-5] 15

For subarray[4-6] 15

 

Editor Image

?