結果

問題 No.91 赤、緑、青の石
ユーザー kenji_shioyakenji_shioya
提出日時 2016-07-01 03:50:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 3,246 ms
コンパイル使用メモリ 73,380 KB
実行使用メモリ 56,360 KB
最終ジャッジ日時 2023-09-06 12:22:14
合計ジャッジ時間 8,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
56,360 KB
testcase_01 AC 141 ms
55,868 KB
testcase_02 AC 131 ms
55,832 KB
testcase_03 AC 142 ms
55,712 KB
testcase_04 AC 134 ms
55,956 KB
testcase_05 AC 141 ms
56,332 KB
testcase_06 AC 131 ms
55,812 KB
testcase_07 AC 119 ms
55,844 KB
testcase_08 AC 120 ms
55,756 KB
testcase_09 AC 119 ms
54,276 KB
testcase_10 AC 117 ms
56,148 KB
testcase_11 AC 137 ms
55,824 KB
testcase_12 AC 146 ms
56,300 KB
testcase_13 AC 146 ms
56,044 KB
testcase_14 AC 140 ms
56,132 KB
testcase_15 AC 138 ms
55,832 KB
testcase_16 AC 113 ms
55,908 KB
testcase_17 AC 120 ms
55,504 KB
testcase_18 AC 125 ms
56,076 KB
testcase_19 AC 129 ms
55,740 KB
testcase_20 AC 124 ms
53,648 KB
testcase_21 AC 124 ms
55,924 KB
testcase_22 AC 124 ms
55,792 KB
testcase_23 AC 124 ms
55,792 KB
testcase_24 AC 122 ms
56,112 KB
testcase_25 AC 140 ms
55,712 KB
testcase_26 AC 146 ms
55,772 KB
testcase_27 AC 114 ms
56,048 KB
testcase_28 AC 127 ms
56,076 KB
testcase_29 AC 129 ms
56,180 KB
testcase_30 AC 145 ms
55,960 KB
testcase_31 AC 148 ms
56,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise140{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();

    while(Math.abs(r - g) > 1 || Math.abs(r - b) > 1) {
      int biggest = Math.max(Math.max(r, g), b);
      int smallest = Math.min(Math.min(r, g), b);
      if(biggest == r){
        r -= 2;
      }else if(biggest == g){
        g -= 2;
      }else if(biggest == b){
        b -= 2;
      }

      if(smallest == r){
        r++;
      }else if(smallest == g){
        g++;
      }else if(smallest == b){
        b++;
      }
    }
    System.out.println(Math.min(Math.min(r, g), b));
  }
}
0