Getting Wrong Answer
Help!!
Question Link-https://codeforces.com/contest/1406/problem/B
Code Link–>https://ide.codingblocks.com/s/334767
Maximum Product Codeforces
can you explain your logic for solving this question.
I have separated all positive numbers and negative numbers present in array and then I have sorted both.
I have considered all six cases
a)five neg,0 pos
b)four neg,1 pos
c)three neg,2 pos and so on.
and calculate max of all six cases without considering zero as element of array
If max sum<0 then if Zero is present in array then, I printed 0 else I printed max sum obtained
you need to make both array a and vector pos and neg long long instead of int moreover you need to intialize each ans with -1e18 not -1e17
Range of a1,a2,…,an (−3×103≤ai≤3×103−3×103≤ai≤3×103)
So at max -ve product will be (3^5)*(10^15),then why -1e18??
value of (3^5)*(10^15) is 7.29 * 10 ^17, which is greater than 10^17 thats why -1e18
Got your point…
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.