Please someone help me with this question

Why i am getting TLE for the question. my logic is that the max value will be for a=ar[n-1] and b=ar[n-2] . There is no nested loop , still getting TLE.

The simplest solution is sort the array then apply the operation on first two elements and on last two elements
say : val1 = (a[0]*a[1]) -(a[0] - a[1])
val2 = (a[n-2] * a[n-1] - (a[n-2] - a[n-1])
ans = max(val1,val2)

my solution : CodeChef: Practical coding for everyone

1 Like

gottcha braw . nice hai !!

you are getting TLE because i think input via Scanner in java is costly you should use fast input output method of java

can you suggest some plugins for vs codes . FOR JAVA , which can gerate basic syntax , etc as soon as i from a class , loke on codechef ide.

I donot know anything about java, but i suppose you could make custom snippets that(for eg how you might get system.out.println when you type sysout), and then customize it so that you get an entire java file ready to code after typing something like .cp and hitting enter( im talking import statements, class names, maybe pre written algorithms etc)

1 Like

thanks man , i was looking for the same things like custome template in cpp. It worked , have created some code snippets ,

1 Like