// cloud.java // Word Cloud, MCPC 2014, Problem E // Java version by Robert Pilgrim import java.io.*; import java.util.Scanner; public class cloudBob { public static void main(String[] args) throws FileNotFoundException { FileReader file = new FileReader("cloud.in"); Scanner in = new Scanner(file); String[] word = new String[100]; int[] height = new int[100]; // height of word in points int[] count = new int[100]; // number of occurences of word int[] width = new int[100]; // width of word in points int set = 0; int cloudcount = 0; while(true) { int w = in.nextInt(); int n = in.nextInt(); if(w==0) break; cloudcount += 1; System.err.println("w = " + w + " n = " + n); int cmax = 0; for(int i=0;icmax) cmax = count[i]; } for(int i=0;i lineheight) lineheight = height[i]; } else { cloudheight += lineheight; lineheight = height[i]; linewidth = width[i]; } } cloudheight += lineheight; System.out.println("CLOUD " + cloudcount + ": " + cloudheight); } in.close(); } }