結果

問題 No.91 赤、緑、青の石
ユーザー kenji_shioya
提出日時 2016-07-01 03:50:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 3,385 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 54,552 KB
最終ジャッジ日時 2024-06-24 06:59:24
合計ジャッジ時間 9,449 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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