結果

問題 No.702 中央値を求めよ LIMITED
ユーザー yuruhiyayuruhiya
提出日時 2020-07-25 21:06:05
言語 Crystal
(1.11.2)
結果
AC  
実行時間 2,152 ms / 5,000 ms
コード長 383 bytes
コンパイル時間 15,090 ms
コンパイル使用メモリ 293,440 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 10:03:01
合計ジャッジ時間 68,539 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,935 ms
5,248 KB
testcase_01 AC 1,962 ms
5,248 KB
testcase_02 AC 1,986 ms
5,376 KB
testcase_03 AC 2,152 ms
5,376 KB
testcase_04 AC 1,964 ms
5,376 KB
testcase_05 AC 1,956 ms
5,376 KB
testcase_06 AC 1,995 ms
5,376 KB
testcase_07 AC 1,975 ms
5,376 KB
testcase_08 AC 1,976 ms
5,376 KB
testcase_09 AC 1,993 ms
5,376 KB
testcase_10 AC 1,963 ms
5,376 KB
testcase_11 AC 1,931 ms
5,376 KB
testcase_12 AC 1,978 ms
5,376 KB
testcase_13 AC 1,948 ms
5,376 KB
testcase_14 AC 2,007 ms
5,376 KB
testcase_15 AC 2,003 ms
5,376 KB
testcase_16 AC 1,994 ms
5,376 KB
testcase_17 AC 1,994 ms
5,376 KB
testcase_18 AC 1,952 ms
5,376 KB
testcase_19 AC 1,981 ms
5,376 KB
testcase_20 AC 1,971 ms
5,376 KB
testcase_21 AC 1,965 ms
5,376 KB
testcase_22 AC 2,003 ms
5,376 KB
testcase_23 AC 1,991 ms
5,376 KB
testcase_24 AC 1,997 ms
5,376 KB
testcase_25 AC 1,995 ms
5,376 KB
testcase_26 AC 1,962 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class XORShift
  def initialize(@x : UInt32)
    @y = 1u32
    @z = 2u32
    @w = 3u32
  end

  def generate
    t = (@x ^ (@x << 11))
    @x, @y, @z = @y, @z, @w
    @w = (@w ^ (@w >> 19)) ^ (t ^ (t >> 8))
  end
end

seed = read_line.to_u32
a = 10000001
puts (UInt32::MIN..UInt32::MAX).bsearch { |x|
  xor = XORShift.new(seed)
  (1..a).count { xor.generate <= x } >= (a // 2 + 1)
}
0