Help Fredo
Practice
4 (49 votes)
Algorithms
Approved
Binary search
Easy
Searching
Problem
77% Success 21912 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Fredo is assigned a task today. He is given an array A containing N integers. His task is to update all elements of array to some minimum value x, that is, \(A[i]=x\) ; \(1≤i≤N\) such that product of all elements of this new array is strictly greater than the product of all elements of the initial array. Note that x should be as minimum as possible such that it meets the given condition. Help him find the value of x.

Input Format:
The first line consists of an integer N , denoting the number of elements in the array.
The next line consists of N space separated integers, denoting the array elements.

Output Format:
The only line of output consists of value of x.

Input Constraints:
\(1 \le N \le 10^5\)
\(1 \le A[i] \le 10^{10}\); \(A[i]\) denoting an array element.

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:30
54 votes
Tags:
AlgorithmsBinary SearchC++
Points:30
13 votes
Tags:
AlgorithmsBinary SearchMathSearching
Points:30
14 votes
Tags:
AlgorithmsApprovedBinary SearchEasyOpenSorting