結果
| 問題 | No.8072 Sum of sqrt(x) |
| ユーザー |
|
| 提出日時 | 2023-03-20 14:15:28 |
| 言語 | Ruby (4.0.2) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 280 bytes |
| 記録 | |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 9,088 KB |
| 実行使用メモリ | 30,720 KB |
| 最終ジャッジ日時 | 2026-04-06 17:08:59 |
| 合計ジャッジ時間 | 67,523 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 TLE * 20 |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.chomp.to_i
xs = n.times.map { gets.chomp.to_i }
@memo = Array.new(n)
def calc_sum(i, xs)
return @memo[i] if @memo[i]
return @memo[i] = Math.sqrt(xs[i]) if i == 0
@memo[i] = calc_sum(i-1, xs) + Math.sqrt(xs[i])
end
(0...n).each do |i|
puts calc_sum(i, xs)
end