結果

問題 No.794 チーム戦 (2)
ユーザー simansiman
提出日時 2022-05-10 17:10:06
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 33,104 KB
最終ジャッジ日時 2023-09-24 23:12:08
合計ジャッジ時間 10,810 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,272 KB
testcase_01 AC 82 ms
15,156 KB
testcase_02 AC 80 ms
15,128 KB
testcase_03 AC 82 ms
15,232 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 85 ms
15,232 KB
testcase_13 AC 83 ms
15,284 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 355 ms
32,276 KB
testcase_17 AC 355 ms
32,316 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 305 ms
30,776 KB
testcase_30 AC 351 ms
30,540 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
MOD = 10 ** 9 + 7

upper = A.select { |a| a > K / 2 }
lower = A.select { |a| a <= K / 2 }

ans = 1
ls = lower.size

upper.each_with_index do |a, i|
  lim = K - a
  idx = lower.bsearch_index { |b| lim < b } || lower.size

  ans *= (idx - i)
  ans = 0 if ans < 0
  ans %= MOD
  ls -= 1
end

ans *= ls * (ls - 1) / 2
ans %= MOD

puts ans
0