結果

問題 No.253 ロウソクの長さ
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-09 21:51:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 73,432 KB
実行使用メモリ 72,896 KB
平均クエリ数 29.78
最終ジャッジ日時 2023-09-23 18:00:10
合計ジャッジ時間 12,873 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 174 ms
71,564 KB
testcase_03 AC 176 ms
70,352 KB
testcase_04 WA -
testcase_05 AC 176 ms
70,360 KB
testcase_06 WA -
testcase_07 AC 179 ms
71,924 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 178 ms
71,668 KB
testcase_11 AC 176 ms
72,068 KB
testcase_12 AC 172 ms
72,064 KB
testcase_13 AC 175 ms
72,032 KB
testcase_14 WA -
testcase_15 AC 179 ms
71,788 KB
testcase_16 AC 176 ms
72,264 KB
testcase_17 AC 176 ms
72,308 KB
testcase_18 AC 176 ms
72,276 KB
testcase_19 WA -
testcase_20 AC 182 ms
72,896 KB
testcase_21 AC 174 ms
70,528 KB
testcase_22 WA -
testcase_23 AC 176 ms
72,060 KB
testcase_24 AC 175 ms
71,612 KB
testcase_25 AC 175 ms
72,432 KB
testcase_26 AC 175 ms
72,100 KB
testcase_27 AC 172 ms
72,492 KB
testcase_28 AC 175 ms
71,976 KB
testcase_29 WA -
testcase_30 AC 177 ms
72,548 KB
testcase_31 AC 181 ms
72,152 KB
testcase_32 AC 179 ms
72,316 KB
testcase_33 AC 177 ms
72,336 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;
        ans = l + p;
      } else if(t == 1) {
        l = med;
        ans = l + 1 + p;
      } else {
        ans = med + p;
        break;
      }
      p++;
    }
    System.out.println("! " + ans);
    System.out.flush();
  }
}
0