結果

問題 No.1501 酔歩
ユーザー kotatsugamekotatsugame
提出日時 2021-05-07 23:02:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 663 ms / 2,000 ms
コード長 315 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 11,436 KB
実行使用メモリ 40,628 KB
最終ジャッジ日時 2023-10-13 14:21:31
合計ジャッジ時間 26,567 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,024 KB
testcase_01 AC 82 ms
14,992 KB
testcase_02 AC 81 ms
15,048 KB
testcase_03 AC 81 ms
15,132 KB
testcase_04 AC 81 ms
15,088 KB
testcase_05 AC 555 ms
33,700 KB
testcase_06 AC 424 ms
30,924 KB
testcase_07 AC 525 ms
32,932 KB
testcase_08 AC 173 ms
19,536 KB
testcase_09 AC 446 ms
32,008 KB
testcase_10 AC 222 ms
21,404 KB
testcase_11 AC 413 ms
30,940 KB
testcase_12 AC 325 ms
25,456 KB
testcase_13 AC 82 ms
15,104 KB
testcase_14 AC 82 ms
15,108 KB
testcase_15 AC 81 ms
15,096 KB
testcase_16 AC 80 ms
15,232 KB
testcase_17 AC 79 ms
15,180 KB
testcase_18 AC 83 ms
15,216 KB
testcase_19 AC 80 ms
15,088 KB
testcase_20 AC 82 ms
15,316 KB
testcase_21 AC 82 ms
15,216 KB
testcase_22 AC 637 ms
40,544 KB
testcase_23 AC 635 ms
40,488 KB
testcase_24 AC 636 ms
40,396 KB
testcase_25 AC 639 ms
40,324 KB
testcase_26 AC 651 ms
40,628 KB
testcase_27 AC 663 ms
40,444 KB
testcase_28 AC 643 ms
40,400 KB
testcase_29 AC 640 ms
40,516 KB
testcase_30 AC 641 ms
40,528 KB
testcase_31 AC 643 ms
40,572 KB
testcase_32 AC 645 ms
40,360 KB
testcase_33 AC 647 ms
40,412 KB
testcase_34 AC 643 ms
40,408 KB
testcase_35 AC 640 ms
40,444 KB
testcase_36 AC 642 ms
40,440 KB
testcase_37 AC 636 ms
40,328 KB
testcase_38 AC 641 ms
40,300 KB
testcase_39 AC 637 ms
40,448 KB
testcase_40 AC 639 ms
40,316 KB
testcase_41 AC 631 ms
40,532 KB
testcase_42 AC 531 ms
40,508 KB
testcase_43 AC 80 ms
15,084 KB
testcase_44 AC 81 ms
15,108 KB
testcase_45 AC 516 ms
40,488 KB
testcase_46 AC 516 ms
40,504 KB
testcase_47 AC 517 ms
40,304 KB
testcase_48 AC 556 ms
40,548 KB
testcase_49 AC 551 ms
40,496 KB
testcase_50 AC 550 ms
40,332 KB
testcase_51 AC 552 ms
40,480 KB
testcase_52 AC 550 ms
40,584 KB
testcase_53 AC 81 ms
15,288 KB
testcase_54 AC 79 ms
15,232 KB
testcase_55 AC 80 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k=gets.split.map &:to_i
a=gets.split.map &:to_r
if n==k
  puts 1r
  exit
end
x=[[0r,0r]]
1.upto(n-2){|i|
  s=a[i-1]+a[i+1]
  l=a[i-1]/s
  r=a[i+1]/s
  b=1-l*x[-1][1]
  x<<[l*x[-1][0]/b,r/b]
}
y=[p]*n
y[n-1]=1r
(n-2).downto(0){|i|
  y[i]=x[i][0]+x[i][1]*y[i+1]
}
ans=y[k-1]
if ans==0r
  puts 0
else
  puts ans
end
0