結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2019-08-10 00:13:51 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 192 ms / 2,000 ms |
コード長 | 1,034 bytes |
コンパイル時間 | 2,738 ms |
コンパイル使用メモリ | 79,084 KB |
実行使用メモリ | 71,004 KB |
平均クエリ数 | 35.08 |
最終ジャッジ日時 | 2024-07-17 02:20:46 |
合計ジャッジ時間 | 10,877 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
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;break;}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();}}