fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. class Main {
  5. public static void main(String[] args) throws Exception {
  6. Scanner in=new Scanner(System.in);
  7. while(in.hasNextInt()) {
  8. int b1=in.nextInt();
  9. int g1=in.nextInt();
  10. int c1=in.nextInt();
  11. int b2=in.nextInt();
  12. int g2=in.nextInt();
  13. int c2=in.nextInt();
  14. int b3=in.nextInt();
  15. int g3=in.nextInt();
  16. int c3=in.nextInt();
  17. int total=b1+g1+c1+b2+g2+c2+b3+g3+c3;
  18.  
  19. String ret="BCG";
  20. int maxv=b1+c2+g3;
  21. if(maxv<b1+g2+c3) {
  22. ret="BGC";
  23. maxv=b1+g2+c3;
  24. }
  25. if(maxv<c1+b2+g3) {
  26. ret="CBG";
  27. maxv=c1+b2+g3;
  28. }
  29. if(maxv<c1+g2+b3) {
  30. ret="CGB";
  31. maxv=c1+g2+b3;
  32. }
  33. if(maxv<g1+b2+c3) {
  34. ret="GBC";
  35. maxv=g1+b2+c3;
  36. }
  37. if(maxv<g1+c2+b3) {
  38. ret="GCB";
  39. maxv=g1+c2+b3;
  40. }
  41. System.out.printf("%s %d%n", ret, total-maxv);
  42. }
  43. }
  44. }
  45.  
Success #stdin #stdout 0.1s 380608KB
stdin
1 2 3 4 5 6 7 8 9
5 10 5 20 10 5 10 20 10
stdout
BCG 30
CBG 50