結果
| 問題 |
No.8072 Sum of sqrt(x)
|
| ユーザー |
|
| 提出日時 | 2023-03-20 14:15:28 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 280 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 36,096 KB |
| 最終ジャッジ日時 | 2024-09-18 14:04:43 |
| 合計ジャッジ時間 | 11,428 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 TLE * 1 -- * 22 |
コンパイルメッセージ
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