textroll/TextRoll_Calvin.java

  1 import java.util.ArrayList;
  2 import java.util.Scanner;
  3 
  4 
  5 public class TextRoll_Calvin {
  6 	public static void main(String[] args) {
  7 		Scanner in = new Scanner(System.in);
  8 		while(in.hasNextLine()) {
  9 			int n = Integer.parseInt(in.nextLine());
 10 			if (n == 0) {
 11 				break;
 12 			}
 13 			ArrayList<String> text = new ArrayList<String>();
 14 			for (int i = 0; i < n; ++i) {
 15 				String _t = in.nextLine();
 16 				text.add(_t);				
 17 			}
 18 			int pointer = 1;
 19 			result:
 20 			for (int i = 0; i < text.size(); ++i) {
 21 				String t = text.get(i);
 22 				for (int j = pointer; j < t.length(); ++j) {
 23 					if (t.charAt(j) == ' ') {
 24 						continue result;
 25 					}
 26 					else {
 27 						++pointer;
 28 					}
 29 				}
 30 			}
 31 			System.out.println(pointer);
 32 		}
 33 		in.close();
 34 	}
 35 }