|
|
back to boardhelp me! I have TLE (java) in.nextToken(); int n = (int) in.nval; byte ch1[] = new byte[n]; byte ch2[] = new byte[n]; while (n > 0) { in.nextToken(); ch1[n - 1] = (byte) in.nval; in.nextToken(); ch2[n - 1] = (byte) in.nval; n--; } int ost = 0; String answer = ""; for (int i = 0; i < ch1.length; i++) { int a = ost + ch1[i] + ch2[i]; if (a > 9) { answer = (a % 10) + answer; ost = a / 10; } else { answer = a + answer; ost = 0; } } out.print(answer); Re: help me! I have TLE (java) Could someone help with time optimization? |
|
|