結果

問題 No.2462 七人カノン
ユーザー simansiman
提出日時 2023-09-10 19:09:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 643 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 11,272 KB
実行使用メモリ 25,684 KB
最終ジャッジ日時 2023-09-10 19:09:58
合計ジャッジ時間 16,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
17,748 KB
testcase_01 AC 112 ms
17,648 KB
testcase_02 AC 110 ms
17,824 KB
testcase_03 AC 121 ms
17,520 KB
testcase_04 AC 119 ms
17,560 KB
testcase_05 AC 121 ms
17,588 KB
testcase_06 AC 123 ms
17,624 KB
testcase_07 AC 118 ms
17,796 KB
testcase_08 AC 120 ms
17,584 KB
testcase_09 AC 118 ms
17,788 KB
testcase_10 AC 118 ms
17,744 KB
testcase_11 AC 117 ms
17,612 KB
testcase_12 AC 121 ms
17,604 KB
testcase_13 AC 522 ms
24,612 KB
testcase_14 AC 515 ms
24,704 KB
testcase_15 AC 485 ms
24,628 KB
testcase_16 AC 581 ms
25,236 KB
testcase_17 AC 584 ms
25,060 KB
testcase_18 AC 195 ms
18,540 KB
testcase_19 AC 201 ms
18,460 KB
testcase_20 AC 597 ms
25,684 KB
testcase_21 AC 617 ms
25,400 KB
testcase_22 AC 619 ms
25,556 KB
testcase_23 AC 608 ms
25,300 KB
testcase_24 AC 405 ms
22,788 KB
testcase_25 AC 643 ms
25,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, Q = gets.split.map(&:to_i)
rui = Array.new(100_010, 0)
scores = Array.new(100_010, 0)
data = []

Q.times do
  i, s, t = gets.split.map(&:to_i)
  rui[s] += 1
  rui[t] -= 1
  data << [i, s, t]
end

1.upto(100_000) do |t|
  rui[t] += rui[t - 1]
end

0.upto(100_000) do |t|
  if rui[t] > 0
    scores[t] = 1.0 / rui[t]
  end
end

rui_scores = [0.0]

scores.each do |x|
  rui_scores << rui_scores.last + x
end

ans = Array.new(N, 0.0)
data.each do |i, s, t|
  ans[i - 1] += rui_scores[t] - rui_scores[s]
end

puts ans
0