結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー tshigtshig
提出日時 2016-08-09 11:52:31
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 514 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-08-21 13:24:06
合計ジャッジ時間 3,869 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,044 KB
testcase_01 AC 78 ms
15,044 KB
testcase_02 AC 78 ms
15,252 KB
testcase_03 AC 77 ms
15,312 KB
testcase_04 AC 79 ms
15,024 KB
testcase_05 AC 78 ms
15,264 KB
testcase_06 AC 81 ms
15,300 KB
testcase_07 AC 78 ms
15,152 KB
testcase_08 AC 80 ms
15,036 KB
testcase_09 AC 79 ms
15,284 KB
testcase_10 WA -
testcase_11 AC 77 ms
15,084 KB
testcase_12 AC 78 ms
15,244 KB
testcase_13 AC 77 ms
15,084 KB
testcase_14 AC 78 ms
15,044 KB
testcase_15 AC 79 ms
15,140 KB
testcase_16 AC 79 ms
15,040 KB
testcase_17 WA -
testcase_18 AC 78 ms
15,044 KB
testcase_19 AC 80 ms
15,124 KB
testcase_20 AC 80 ms
15,320 KB
testcase_21 AC 80 ms
15,076 KB
testcase_22 AC 82 ms
15,252 KB
testcase_23 AC 83 ms
15,156 KB
testcase_24 AC 80 ms
15,272 KB
testcase_25 AC 81 ms
15,264 KB
testcase_26 AC 80 ms
15,272 KB
testcase_27 WA -
testcase_28 AC 78 ms
15,044 KB
testcase_29 AC 78 ms
15,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Calc0081
  def initialize(args)
    args = args.map { |l| l.chomp.split(/\s+/) }
    @n = args.shift.first.to_i
    @as = args.map(&:first)
  end

  def run
    sum = @as.map { |a|
      t = a.split('.')
      t0 = t[0].to_i * 10 ** 10
      t1 = (t[1] || '').ljust(10, '0').to_i * (a.start_with?('-') ? -1 : 1)
      t0 + t1
    }.inject(:+)

    sign = sum >= 0 ? 1 : -1
    "%d.%010d" % [(sum.abs / 10 ** 10) * sign, sum.abs % 10 ** 10]
  end
end

puts Calc0081.new(STDIN.readlines).run if __FILE__ == $0
0