UVA 102


SUBMITTED BY: Guest

DATE: Dec. 5, 2013, 3:19 p.m.

FORMAT: Java

SIZE: 2.2 kB

HITS: 993

  1. import java.util.*;
  2. public class Main {
  3. public static void main(String[] args) {
  4. // write your code here
  5. Scanner sc = new Scanner(System.in);
  6. int count,tmp,min;
  7. int i,j;
  8. String result;
  9. while(true){
  10. count = tmp = 0;
  11. min = Integer.MAX_VALUE;
  12. result = "";
  13. if(!sc.hasNext()) {
  14. break;
  15. }
  16. int[] B = new int[3];
  17. int[] G = new int[3];
  18. int[] C = new int[3];
  19. B[0] = sc.nextInt();
  20. G[0] = sc.nextInt();
  21. C[0] = sc.nextInt();
  22. B[1] = sc.nextInt();
  23. G[1] = sc.nextInt();
  24. C[1] = sc.nextInt();
  25. B[2] = sc.nextInt();
  26. G[2] = sc.nextInt();
  27. C[2] = sc.nextInt();
  28. //BCG
  29. tmp = G[0] + C[0] + B[1] + B[2] + G[1] + C[2];
  30. if(tmp<min){
  31. min = tmp;
  32. result = "BCG";
  33. }
  34. //BGC
  35. tmp = G[0] + C[0] + B[1] + C[1] + B[2] + G[2];
  36. if(tmp<min){
  37. min = tmp;
  38. result = "BGC";
  39. }
  40. //CBG
  41. tmp = B[0] + G[0] + G[1] + C[1] + B[2] + C[2];
  42. if(tmp<min){
  43. min = tmp;
  44. result = "CBG";
  45. }
  46. //CGB
  47. tmp = B[0] + G[0] + B[1] + C[1] + C[2] + G[2];
  48. if(tmp<min){
  49. min = tmp;
  50. result = "CGB";
  51. }
  52. //GBC
  53. tmp = B[0] + C[0] + C[1] + G[1] + B[2] + G[2];
  54. if(tmp<min){
  55. min = tmp;
  56. result = "GBC";
  57. }
  58. //GCB
  59. tmp = B[0] + C[0] + B[1] + G[1] + G[2] + C[2];
  60. if(tmp<min){
  61. min = tmp;
  62. result = "GCB";
  63. }
  64. System.out.println(result + " " + min);
  65. }
  66. }
  67. }

comments powered by Disqus