結果

問題 No.253 ロウソクの長さ
ユーザー 37zigen37zigen
提出日時 2016-03-22 17:36:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,184 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 74,960 KB
平均クエリ数 34.19
最終ジャッジ日時 2023-09-23 23:21:58
合計ジャッジ時間 10,612 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 188 ms
70,932 KB
testcase_01 AC 165 ms
72,508 KB
testcase_02 AC 180 ms
72,100 KB
testcase_03 AC 167 ms
72,400 KB
testcase_04 AC 168 ms
71,408 KB
testcase_05 AC 178 ms
71,704 KB
testcase_06 AC 193 ms
72,492 KB
testcase_07 AC 192 ms
72,612 KB
testcase_08 AC 191 ms
72,292 KB
testcase_09 AC 159 ms
71,852 KB
testcase_10 AC 191 ms
72,468 KB
testcase_11 AC 183 ms
72,576 KB
testcase_12 AC 182 ms
73,028 KB
testcase_13 AC 182 ms
72,692 KB
testcase_14 AC 168 ms
71,732 KB
testcase_15 AC 179 ms
72,396 KB
testcase_16 AC 168 ms
71,112 KB
testcase_17 AC 141 ms
71,636 KB
testcase_18 AC 186 ms
72,116 KB
testcase_19 AC 159 ms
72,136 KB
testcase_20 AC 186 ms
72,940 KB
testcase_21 AC 171 ms
72,124 KB
testcase_22 AC 167 ms
71,292 KB
testcase_23 AC 185 ms
70,952 KB
testcase_24 AC 179 ms
71,740 KB
testcase_25 AC 188 ms
73,220 KB
testcase_26 AC 188 ms
72,900 KB
testcase_27 AC 192 ms
74,960 KB
testcase_28 AC 190 ms
72,896 KB
testcase_29 AC 187 ms
73,228 KB
testcase_30 AC 187 ms
73,248 KB
testcase_31 AC 188 ms
72,736 KB
testcase_32 AC 189 ms
72,416 KB
testcase_33 AC 186 ms
72,108 KB
testcase_34 AC 156 ms
71,972 KB
testcase_35 AC 182 ms
71,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder253;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		System.out.println("?100");
		System.err.println(1000000000);
		int a=sc.nextInt();
		int count=0;
		if(a==-1){
			for(int i=0;i<100;i++){
				System.out.println("?0");
				count++;
				int b=sc.nextInt();
				if(b==0){
					System.out.println("!"+count);
					sc.close();
					System.exit(0);
				}
			}
		}else if(a==1){
			int upper=(int)Math.pow(10,9);
			int low=101;
			int mid;
			int ans=1000000000;
			while(low!=upper){
				count++;
				upper--;
				low--;
				ans--;
				mid=(int)(upper+low)/2;
				System.out.println("?"+mid);
				System.err.println("ans="+ans);
				System.err.println("upper="+upper+" low="+low);
				int r=sc.nextInt();
				if(r==1){
					if(upper==low+1){
						System.out.println("!"+(upper+count));
						sc.close();
						System.exit(0);
					}
					low=mid;
				}else if(r==-1){
					upper=mid;
				}else if(r==0){
					System.out.println("!"+(mid+count));
					sc.close();
					System.exit(0);
				}
			}
		}else if(a==0){
			System.out.println("!100");
			sc.close();
			System.exit(0);
		}

	}
}

0