結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー code-devocode-devo
提出日時 2016-01-20 06:02:34
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 377 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 15,548 KB
最終ジャッジ日時 2023-08-21 13:21:35
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,040 KB
testcase_01 AC 81 ms
15,260 KB
testcase_02 AC 80 ms
15,180 KB
testcase_03 AC 79 ms
15,124 KB
testcase_04 AC 82 ms
15,124 KB
testcase_05 AC 78 ms
15,180 KB
testcase_06 AC 81 ms
15,088 KB
testcase_07 AC 79 ms
15,096 KB
testcase_08 AC 82 ms
15,092 KB
testcase_09 AC 79 ms
15,168 KB
testcase_10 WA -
testcase_11 AC 80 ms
15,092 KB
testcase_12 AC 80 ms
15,044 KB
testcase_13 AC 79 ms
15,172 KB
testcase_14 AC 76 ms
15,224 KB
testcase_15 AC 77 ms
15,064 KB
testcase_16 AC 77 ms
15,236 KB
testcase_17 WA -
testcase_18 AC 80 ms
15,048 KB
testcase_19 AC 78 ms
15,092 KB
testcase_20 AC 77 ms
15,148 KB
testcase_21 AC 79 ms
15,300 KB
testcase_22 AC 79 ms
15,056 KB
testcase_23 AC 79 ms
15,096 KB
testcase_24 AC 80 ms
15,340 KB
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 81 ms
15,340 KB
testcase_29 AC 80 ms
15,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

D = 10

wn_sum = 0
dn_sum = 0

gets
while line = gets do
  case line
  when /(-?)(\d+)\.(\d+)/ then
    sign, wn, dn = $1, $2.to_i, $3.ljust(D, "0").to_i
  when /(-?)(\d+)/
    sign, wn, dn = $1, $2.to_i, 0
  end
  if sign == "-" then
    wn_sum -= wn
    dn_sum -= dn
  else
    wn_sum += wn
    dn_sum += dn
  end
end

puts (wn_sum * 10 ** D + dn_sum).to_s.insert(-D-1, ".")
0