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 1881. Long problem statement

Despair and Test Case #6
Posted by Aleksandr 25 Jan 2017 04:16
I have successfully completed all tests given in the "Discussion" but for some reason test number SIX does not think so.

Maybe somebody can give me the inputs and the expected answer? Much appreciated!
Re: Despair and Test Case #6
Posted by Aleksandr 25 Jan 2017 20:06
BUMP

Ok, maybe after looking at the code anyone could tell me anything :)

public class Timus {

    public static void main (String []args) throws IOException
    {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String mn[] = in.readLine().split(" ");
        byte     totalPages = 1,
                h = Byte.parseByte(mn[0]),  // lines on a page
                currentLines = 1,
                w = Byte.parseByte(mn[1]),    // symbols in a line
                currentSymbols = 0;
        short     n = Short.parseShort(mn[2]);// ALL words
        String     s = "";                        // current word


        for (int i = 0; i < n; i++)
        {
            s = in.readLine();
            if (currentSymbols + s.length() <= w)
                currentSymbols += s.length() + 1;
            else
            {
                currentSymbols = (byte) (s.length() + 1);
                if (currentLines + 1 <= h)
                    currentLines++;
                else
                {
                    totalPages++;
                    currentLines = 1;
                }
            }
        }

        out.print(totalPages);
        out.flush();
    }