結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー simansiman
提出日時 2021-07-29 08:20:32
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 410 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-10-12 06:33:03
合計ジャッジ時間 5,021 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,052 KB
testcase_01 AC 82 ms
15,056 KB
testcase_02 AC 82 ms
15,184 KB
testcase_03 AC 82 ms
15,172 KB
testcase_04 AC 84 ms
15,160 KB
testcase_05 AC 83 ms
15,116 KB
testcase_06 AC 83 ms
15,276 KB
testcase_07 AC 83 ms
15,256 KB
testcase_08 AC 84 ms
15,312 KB
testcase_09 AC 86 ms
15,064 KB
testcase_10 WA -
testcase_11 AC 82 ms
15,248 KB
testcase_12 AC 84 ms
15,120 KB
testcase_13 AC 83 ms
15,048 KB
testcase_14 AC 83 ms
15,184 KB
testcase_15 AC 84 ms
15,184 KB
testcase_16 AC 82 ms
15,044 KB
testcase_17 AC 83 ms
15,144 KB
testcase_18 AC 82 ms
15,252 KB
testcase_19 AC 81 ms
15,192 KB
testcase_20 AC 83 ms
15,144 KB
testcase_21 AC 83 ms
15,264 KB
testcase_22 AC 83 ms
15,056 KB
testcase_23 AC 83 ms
15,144 KB
testcase_24 AC 82 ms
15,172 KB
testcase_25 AC 81 ms
15,060 KB
testcase_26 WA -
testcase_27 AC 83 ms
15,232 KB
testcase_28 AC 83 ms
15,200 KB
testcase_29 AC 84 ms
15,196 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = N.times.map { gets.chomp }
g = 10 ** 10
sum = 0

A.each do |a|
  i, f = a.split('.')
  f = '0' if f.nil?

  v = i.to_i.abs * g + f.ljust(10, '0').to_i

  if a[0] == '-'
    v *= -1
  end

  sum += v
end

if sum == 0
  puts "0.0000000000"
elsif -1.0 * g < sum && sum < 0
  while sum.abs.to_s.size < 10
    sum *= 10
  end

  puts "-0." + sum.abs.to_s
else
  puts sum.to_s.insert(-11, '.')
end
0