結果
問題 | No.253 ロウソクの長さ |
ユーザー | Grenache |
提出日時 | 2015-07-27 17:02:28 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 2,188 bytes |
コンパイル時間 | 3,432 ms |
コンパイル使用メモリ | 75,056 KB |
実行使用メモリ | 72,248 KB |
平均クエリ数 | 48.97 |
最終ジャッジ日時 | 2023-09-23 21:02:18 |
合計ジャッジ時間 | 10,937 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
72,208 KB |
testcase_01 | AC | 144 ms
71,128 KB |
testcase_02 | AC | 147 ms
69,556 KB |
testcase_03 | AC | 140 ms
71,420 KB |
testcase_04 | AC | 139 ms
69,540 KB |
testcase_05 | AC | 148 ms
72,092 KB |
testcase_06 | AC | 148 ms
71,932 KB |
testcase_07 | AC | 147 ms
71,368 KB |
testcase_08 | AC | 144 ms
71,360 KB |
testcase_09 | AC | 132 ms
71,960 KB |
testcase_10 | AC | 145 ms
71,748 KB |
testcase_11 | AC | 148 ms
71,824 KB |
testcase_12 | AC | 151 ms
71,576 KB |
testcase_13 | AC | 146 ms
72,020 KB |
testcase_14 | AC | 131 ms
71,880 KB |
testcase_15 | AC | 148 ms
71,404 KB |
testcase_16 | AC | 139 ms
71,420 KB |
testcase_17 | AC | 148 ms
71,304 KB |
testcase_18 | AC | 147 ms
71,508 KB |
testcase_19 | AC | 132 ms
71,824 KB |
testcase_20 | AC | 147 ms
71,652 KB |
testcase_21 | AC | 144 ms
71,888 KB |
testcase_22 | AC | 138 ms
71,624 KB |
testcase_23 | AC | 151 ms
71,672 KB |
testcase_24 | AC | 150 ms
72,088 KB |
testcase_25 | AC | 152 ms
71,584 KB |
testcase_26 | AC | 152 ms
69,704 KB |
testcase_27 | AC | 151 ms
71,312 KB |
testcase_28 | AC | 151 ms
72,248 KB |
testcase_29 | AC | 154 ms
72,144 KB |
testcase_30 | AC | 154 ms
71,648 KB |
testcase_31 | AC | 151 ms
71,636 KB |
testcase_32 | AC | 147 ms
72,060 KB |
testcase_33 | AC | 148 ms
72,084 KB |
testcase_34 | AC | 132 ms
71,768 KB |
testcase_35 | AC | 142 ms
71,436 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; public class Main_yukicoder253 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int count = 1; if (ask(sc, pr, 40) < 0) { while (ask(sc, pr, 9) > 0) { count++; } pr.printf("! %d\n", 9 + count); } else { int l = 39; int r = 1000000001; while (r > l) { int mid = (r + l) / 2; count++; if (ask(sc, pr, mid) <= 0) { r = mid; } else { l = mid + 1; } } int tmp = r - count; while (ask(sc, pr, tmp) > 0) { count++; } pr.printf("! %d\n", tmp + count); } pr.close(); sc.close(); } private static int ask(Scanner sc, Printer pr, int i) { pr.printf("? %d\n", i); pr.flush(); return sc.nextInt(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }