結果

問題 No.2462 七人カノン
ユーザー siman
提出日時 2023-09-10 19:09:41
言語 Ruby
(3.4.1)
結果
AC  
実行時間 641 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 22,656 KB
最終ジャッジ日時 2024-06-28 10:18:20
合計ジャッジ時間 15,141 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
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