結果

問題 No.253 ロウソクの長さ
ユーザー maimai
提出日時 2016-06-01 12:49:57
言語 Ruby
(3.2.2)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 31,472 KB
平均クエリ数 26.53
最終ジャッジ日時 2023-09-24 00:03:19
合計ジャッジ時間 6,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
31,244 KB
testcase_01 AC 99 ms
31,324 KB
testcase_02 AC 103 ms
30,948 KB
testcase_03 AC 98 ms
31,076 KB
testcase_04 AC 100 ms
30,784 KB
testcase_05 AC 100 ms
30,968 KB
testcase_06 AC 101 ms
31,128 KB
testcase_07 AC 100 ms
31,140 KB
testcase_08 AC 97 ms
30,984 KB
testcase_09 AC 100 ms
30,740 KB
testcase_10 AC 102 ms
31,172 KB
testcase_11 AC 104 ms
31,424 KB
testcase_12 AC 103 ms
31,364 KB
testcase_13 AC 101 ms
31,396 KB
testcase_14 AC 99 ms
30,916 KB
testcase_15 AC 102 ms
30,820 KB
testcase_16 AC 99 ms
30,940 KB
testcase_17 AC 98 ms
30,952 KB
testcase_18 AC 102 ms
31,252 KB
testcase_19 AC 101 ms
31,472 KB
testcase_20 AC 101 ms
31,064 KB
testcase_21 AC 98 ms
31,068 KB
testcase_22 AC 100 ms
30,820 KB
testcase_23 AC 102 ms
31,352 KB
testcase_24 AC 101 ms
31,064 KB
testcase_25 AC 105 ms
31,204 KB
testcase_26 AC 102 ms
31,152 KB
testcase_27 AC 104 ms
30,696 KB
testcase_28 AC 102 ms
31,176 KB
testcase_29 AC 103 ms
31,428 KB
testcase_30 AC 104 ms
30,768 KB
testcase_31 AC 104 ms
30,968 KB
testcase_32 AC 103 ms
31,472 KB
testcase_33 AC 98 ms
30,904 KB
testcase_34 AC 99 ms
30,988 KB
testcase_35 AC 102 ms
30,972 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#@target=251
#def simulate(m)
#    r=m>@target ? -1 : m<@target ? 1 : 0
#    @target-=1
#    return r
#end

puts "? 40";STDOUT.flush
s=gets.to_i
#s=simulate(40)
if s==0
    puts "! 40";STDOUT.flush;exit
elsif s<0
    1.upto(40){|i|
        puts "? 9";STDOUT.flush
        if gets.to_i==0 #simulate(9)==0
            puts "! "+(9+i).to_s
            exit
        end
    }
    
end

q=1
l=1;h=10**9
50.times{
    m=(h+l+1)/2;
    puts "? "+m.to_s;STDOUT.flush
    s=gets.to_i
    #s=simulate(m)
    if s==0
        puts "! "+(m+q).to_s
        exit
    elsif s<0
        h=m-1
    else
        l=m+1
    end
    q+=1
    l-=1
    h-=1
    #p [q,l,h,m,@target]
}
0