Please help!! what is the fastest way to get input in java and also to optimize the code to get least runtime?? thanks!

for enormous input output problem i m getting runtime 8.39 and i think its huge please help!!
thanks!
my solution link:

http://www.codechef.com/viewsolution/5729147

You got AC, where is the problem?

Two easy tips, do not use split, use StringTokenizer. You also do not need to allocate array a.

I consider those as micro enhancements if you are using basic optimizations, it should be ok and you have to make your code quicker by implementing better algorithm…

I also want to know that how we can take large inputs in java…in jan15 long contest my solution for onr of the problem was accepted for one subtask but it was not for another subtask with larger set even after i have used long instead of int.

is there any other way out to take large inputs please suggest!! thanks!

Yes i have got the ac but the time was 8.39 which was quite large.but i have tried it without array and time has reduced to 8.20.

I also want to know that how we can take large inputs in java…in jan15 long contest my solution was accepted for one subtask but it was not for another subtask with larger set even after i have used long instead of int.

is there any other way out to take large inputs please suggest!! thanks!

I’m facing same problem, here is a nice answer for fast IO in Java - How to submit java code? - #3 by pikaynu - help - CodeChef Discuss

Thanks Betista i got it!!