import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author kuric10 */ public class Stavitel { private static int row, col, pocTC,pocMin,pocMax; private static int r[] = new int [101]; private static int c[] = new int [101]; private static int rr[] = new int [101]; private static int cc[] = new int [101]; /** * @param args the command line arguments */ public static void main(String[] args)throws IOException{ // TODO code application logic here BufferedReader input = new BufferedReader(new InputStreamReader(System.in)) ; String s, poleS[]; pocTC = Integer.parseInt(input.readLine()); for (int i = 0; i < pocTC; i++) { row = Integer.parseInt(input.readLine()); s = input.readLine(); pocMin = 0; poleS= s.split(" "); for (int j = 0; j < row; j++) { r[j]= Integer.parseInt(poleS[j]); rr[j] = r[j]; pocMin += r[j]; } s = input.readLine(); poleS= s.split(" "); for (int j = 0; j < row; j++) { c[j]= Integer.parseInt(poleS[j]); cc[j] = c[j]; pocMin += c[j]; } pocMax = 0; // System.out.println(pocMin); for (int j = 0; j < row; j++) { for (int k = 0; k < row; k++) { pocMax += Math.min(r[j], c[k]); if(cc[k]==rr[j]/*||cc[j]>rr[j]*/){ pocMin -= cc[k]; // System.out.println(cc[k]); cc[k]=0; rr[j]=0; } } } System.out.println("Minimalni budova obsahuje "+pocMin+" kostek, maximalni "+pocMax+" kostek."); } while((s=input.readLine())!=null){ row = Integer.parseInt(s); col = Integer.parseInt(input.readLine()); for (int i = 0; i < row; i++) { s = input.readLine(); poleS= s.split(" "); for (int j = 0; j < col; j++) { } } } } }