結果

問題 No.253 ロウソクの長さ
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-09 20:26:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 73,012 KB
実行使用メモリ 73,804 KB
平均クエリ数 29.33
最終ジャッジ日時 2023-09-23 17:59:54
合計ジャッジ時間 14,556 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 178 ms
71,840 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 171 ms
71,764 KB
testcase_06 WA -
testcase_07 AC 174 ms
71,516 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 175 ms
72,108 KB
testcase_11 WA -
testcase_12 AC 176 ms
71,952 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 176 ms
72,088 KB
testcase_16 AC 179 ms
72,220 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 177 ms
72,044 KB
testcase_22 WA -
testcase_23 AC 179 ms
71,776 KB
testcase_24 WA -
testcase_25 AC 180 ms
72,236 KB
testcase_26 WA -
testcase_27 AC 175 ms
71,828 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 180 ms
71,648 KB
testcase_31 WA -
testcase_32 AC 175 ms
72,152 KB
testcase_33 AC 171 ms
71,936 KB
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int p = 0;
    int l = 0;
    int r = (int)Math.pow(10, 9) + 1;
    int ans = 0;
    while(l < r) {
      int med = (l + r) / 2;
      System.out.println("? " + med);
      System.out.flush();
      int t = sc.nextInt();
      if(t == -1) {
        r = med - 1;
        p++;
      } else if(t == 1) {
        l = med;
        p++;
      } else {
        ans = med + p;
        System.out.println("! " + ans);
        System.out.flush();
        break;
      }
    }
  }
}
0