結果

問題 No.253 ロウソクの長さ
ユーザー KilisameKilisame
提出日時 2016-09-30 16:03:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 3,676 ms
コンパイル使用メモリ 74,292 KB
実行使用メモリ 72,668 KB
平均クエリ数 21.22
最終ジャッジ日時 2023-09-24 00:34:58
合計ジャッジ時間 11,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
72,460 KB
testcase_01 AC 142 ms
71,760 KB
testcase_02 AC 140 ms
71,796 KB
testcase_03 AC 138 ms
71,628 KB
testcase_04 AC 139 ms
72,076 KB
testcase_05 AC 139 ms
72,264 KB
testcase_06 AC 144 ms
71,796 KB
testcase_07 AC 146 ms
71,820 KB
testcase_08 AC 143 ms
70,052 KB
testcase_09 AC 134 ms
71,956 KB
testcase_10 AC 149 ms
72,056 KB
testcase_11 AC 154 ms
72,140 KB
testcase_12 AC 145 ms
72,032 KB
testcase_13 AC 146 ms
71,776 KB
testcase_14 AC 138 ms
72,484 KB
testcase_15 AC 142 ms
71,488 KB
testcase_16 AC 140 ms
71,692 KB
testcase_17 AC 138 ms
71,756 KB
testcase_18 AC 144 ms
69,896 KB
testcase_19 AC 139 ms
72,304 KB
testcase_20 AC 151 ms
69,980 KB
testcase_21 AC 140 ms
71,904 KB
testcase_22 AC 140 ms
70,128 KB
testcase_23 AC 148 ms
72,280 KB
testcase_24 AC 140 ms
72,028 KB
testcase_25 AC 146 ms
72,668 KB
testcase_26 AC 144 ms
71,632 KB
testcase_27 AC 142 ms
72,340 KB
testcase_28 AC 146 ms
72,596 KB
testcase_29 AC 146 ms
71,784 KB
testcase_30 AC 143 ms
72,236 KB
testcase_31 AC 143 ms
72,264 KB
testcase_32 AC 151 ms
71,672 KB
testcase_33 AC 145 ms
70,020 KB
testcase_34 AC 137 ms
69,420 KB
testcase_35 AC 144 ms
71,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package puzzle.yukicoder.lengthofcandle;

import java.util.Scanner;

public class Lengthofcandle {

    public static void main(String[] args) {
        int min = 10;
        int max = 1000000001;
        int current = 100;
        Scanner cin = new Scanner(System.in);
        for (int i = 0; i < 100; i++) {
            /* 単純に2分探索したい。しかし、長さが100以下の場合、途中で燃え尽きてしまうため、探索の開始は100とする */
            System.out.println("? " + (current - i));
            System.out.flush();
            String result = cin.nextLine();
            if (result.equals("0")) {
                System.out.println("! " + current);
                System.out.flush();
                System.exit(0);
            } else if (result.equals("1")) {
                min = current;
            } else {
                max = current;
            }
            current = (min + max) / 2;
        }
    }

}
0