結果

問題 No.253 ロウソクの長さ
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-10 00:10:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,017 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 75,516 KB
実行使用メモリ 74,372 KB
平均クエリ数 58.25
最終ジャッジ日時 2023-09-23 18:00:34
合計ジャッジ時間 13,674 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
72,024 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 176 ms
72,292 KB
testcase_07 AC 171 ms
72,340 KB
testcase_08 AC 174 ms
71,964 KB
testcase_09 WA -
testcase_10 AC 177 ms
72,016 KB
testcase_11 AC 175 ms
72,124 KB
testcase_12 AC 176 ms
72,116 KB
testcase_13 AC 178 ms
72,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 177 ms
71,604 KB
testcase_18 AC 174 ms
71,632 KB
testcase_19 WA -
testcase_20 AC 178 ms
70,480 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 176 ms
72,484 KB
testcase_24 WA -
testcase_25 AC 173 ms
72,056 KB
testcase_26 AC 176 ms
73,744 KB
testcase_27 AC 175 ms
71,644 KB
testcase_28 AC 174 ms
71,624 KB
testcase_29 AC 175 ms
72,304 KB
testcase_30 AC 172 ms
72,392 KB
testcase_31 AC 176 ms
72,056 KB
testcase_32 AC 173 ms
72,424 KB
testcase_33 AC 176 ms
72,352 KB
testcase_34 WA -
testcase_35 AC 176 ms
71,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int p = 1;
    int l = 0;
    int r = (int)Math.pow(10, 9) + 1;
    int ans = 0;
    System.out.println("? " + 99);
    System.out.flush();
    int res = sc.nextInt();
    if(res == -1) {
      for(int i = 0; i < 99; i++) {
        System.out.println("? " + 0);
        System.out.flush();
        int t = sc.nextInt();
        if(t == 0) {
          ans = p; 
        }
        p++;
      }
    } else {
      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;
          l--;
        } else if(t == 1) {
          l = med;
          ans = l + 1 + p;
          r--;
        } else {
          ans = med + p;
          break;
        }
        p++;
      }
    }
    System.out.println("! " + ans);
    System.out.flush();
  }
}
0