結果
問題 | No.253 ロウソクの長さ |
ユーザー | Grenache |
提出日時 | 2015-07-27 17:02:28 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 166 ms / 2,000 ms |
コード長 | 2,188 bytes |
コンパイル時間 | 3,947 ms |
コンパイル使用メモリ | 78,496 KB |
実行使用メモリ | 58,268 KB |
平均クエリ数 | 48.97 |
最終ジャッジ日時 | 2024-07-16 20:51:43 |
合計ジャッジ時間 | 11,586 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 163 ms
57,128 KB |
testcase_01 | AC | 142 ms
58,036 KB |
testcase_02 | AC | 145 ms
58,068 KB |
testcase_03 | AC | 146 ms
57,256 KB |
testcase_04 | AC | 137 ms
58,192 KB |
testcase_05 | AC | 146 ms
57,440 KB |
testcase_06 | AC | 148 ms
57,968 KB |
testcase_07 | AC | 148 ms
57,736 KB |
testcase_08 | AC | 154 ms
57,104 KB |
testcase_09 | AC | 146 ms
57,768 KB |
testcase_10 | AC | 163 ms
57,564 KB |
testcase_11 | AC | 151 ms
57,028 KB |
testcase_12 | AC | 164 ms
57,776 KB |
testcase_13 | AC | 151 ms
57,832 KB |
testcase_14 | AC | 138 ms
57,200 KB |
testcase_15 | AC | 147 ms
57,824 KB |
testcase_16 | AC | 155 ms
57,876 KB |
testcase_17 | AC | 150 ms
57,748 KB |
testcase_18 | AC | 152 ms
58,224 KB |
testcase_19 | AC | 153 ms
57,968 KB |
testcase_20 | AC | 154 ms
57,940 KB |
testcase_21 | AC | 144 ms
58,084 KB |
testcase_22 | AC | 141 ms
57,184 KB |
testcase_23 | AC | 164 ms
57,816 KB |
testcase_24 | AC | 146 ms
58,080 KB |
testcase_25 | AC | 166 ms
58,096 KB |
testcase_26 | AC | 152 ms
56,952 KB |
testcase_27 | AC | 152 ms
56,976 KB |
testcase_28 | AC | 150 ms
56,952 KB |
testcase_29 | AC | 150 ms
58,220 KB |
testcase_30 | AC | 151 ms
57,836 KB |
testcase_31 | AC | 161 ms
57,564 KB |
testcase_32 | AC | 147 ms
57,388 KB |
testcase_33 | AC | 153 ms
57,216 KB |
testcase_34 | AC | 150 ms
57,560 KB |
testcase_35 | AC | 147 ms
58,268 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); } } }