|  | 
|  | 
| вернуться в форум | Despair and Test Case #6 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 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();
 }
 | 
 | 
|