The simplest solution is sort the array then apply the operation on first two elements and on last two elements
say : val1 = (a*a) -(a - a)
val2 = (a[n-2] * a[n-1] - (a[n-2] - a[n-1])
ans = max(val1,val2)
my solution : CodeChef: Practical coding for everyone
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)
thanks man , i was looking for the same things like custome template in cpp. It worked , have created some code snippets ,