結果

問題 No.91 赤、緑、青の石
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-06 20:50:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 810 bytes
コンパイル時間 1,910 ms
コンパイル使用メモリ 71,520 KB
実行使用メモリ 56,456 KB
最終ジャッジ日時 2023-09-06 12:43:04
合計ジャッジ時間 7,224 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,908 KB
testcase_01 AC 126 ms
55,812 KB
testcase_02 AC 128 ms
55,772 KB
testcase_03 AC 125 ms
55,564 KB
testcase_04 AC 124 ms
56,456 KB
testcase_05 AC 125 ms
55,928 KB
testcase_06 AC 124 ms
55,776 KB
testcase_07 AC 124 ms
56,092 KB
testcase_08 AC 126 ms
56,040 KB
testcase_09 AC 125 ms
56,044 KB
testcase_10 AC 125 ms
56,000 KB
testcase_11 AC 123 ms
55,992 KB
testcase_12 AC 123 ms
55,692 KB
testcase_13 AC 124 ms
56,228 KB
testcase_14 AC 127 ms
55,828 KB
testcase_15 AC 124 ms
55,780 KB
testcase_16 AC 124 ms
55,796 KB
testcase_17 AC 123 ms
55,768 KB
testcase_18 AC 123 ms
55,748 KB
testcase_19 AC 123 ms
55,760 KB
testcase_20 AC 126 ms
55,892 KB
testcase_21 AC 122 ms
56,052 KB
testcase_22 AC 122 ms
56,324 KB
testcase_23 AC 123 ms
55,580 KB
testcase_24 AC 125 ms
55,572 KB
testcase_25 AC 123 ms
55,800 KB
testcase_26 AC 124 ms
55,876 KB
testcase_27 AC 125 ms
55,712 KB
testcase_28 AC 125 ms
55,716 KB
testcase_29 AC 124 ms
55,996 KB
testcase_30 AC 124 ms
55,548 KB
testcase_31 AC 126 ms
55,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();
    int G = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    int l = 0;
    int r = 10000001;
    while(l < r) {
      int med = (l + r) / 2;
      int plus = 0;
      int minus = 0;
      if(R >= med) {
        plus += ((R - med) / 2);
      } else {
        minus += (med - R);
      }

      if(G >= med) {
        plus += ((G - med) / 2);
      } else {
        minus += (med - G);
      }

      if(B >= med) {
        plus += ((B - med) / 2);
      } else {
        minus += (med - B);
      }

      if(plus >= minus) {
        ans = med;
        l = med + 1;
      } else {
        r = med;
      }
    }
    System.out.println(ans);
  }
}
0