SPOJ 3440 "Enormous Input and Output Test" INOUTEST

問題:https://www.spoj.pl/problems/INOUTEST/

巨大な入力に対して巨大な出力をするテスト.
入力は別の問題でテストできるので出力でちょっと試した.


入力:System.inで自作.
出力:PrintWriter(4.39s) System.out(TLE)


出力:PrintWriter
時間:4.39s

public class Main {
	public static void main(String[] args) throws Exception{
		java.io.PrintWriter pw=new java.io.PrintWriter(System.out);
		for(int t=next();t-->0;){
			pw.println(next()*next());
		}
		pw.close();
	}
	static int next() throws Exception {
		int result = 0;
		int b = ' ';
		for (; b == '\n' || b == ' ';) {
			b = System.in.read();
		}
		int seg=1;
		if(b=='-'){
			seg=-1;
			b=System.in.read();
		}
		for (; '0' <= b && b <= '9';) {
			result = result * 10 + b - '0';
			b = System.in.read();
		}
		return seg*result;
	}
}

出力:System.out
時間:TLE

public class Main {
	public static void main(String[] args) throws Exception{
		for(int t=next();t-->0;){
			System.out.println(next()*next());
		}
	}
	static int next() throws Exception {
		int result = 0;
		int b = ' ';
		for (; b == '\n' || b == ' ';) {
			b = System.in.read();
		}
		int seg=1;
		if(b=='-'){
			seg=-1;
			b=System.in.read();
		}
		for (; '0' <= b && b <= '9';) {
			result = result * 10 + b - '0';
			b = System.in.read();
		}
		return seg*result;
	}
}