ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1048. Superlong Sums

help me! I have TLE (java)
Posted by Zhassulan 29 Jan 2015 14:38
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)
Posted by Zhassulan 3 Feb 2015 14:38
Could someone help with time optimization?