結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー LeonardoneLeonardone
提出日時 2016-09-30 06:23:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 664 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 57,088 KB
最終ジャッジ日時 2024-05-01 08:09:10
合計ジャッジ時間 6,485 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
12,288 KB
testcase_01 AC 92 ms
12,160 KB
testcase_02 AC 91 ms
12,160 KB
testcase_03 AC 91 ms
12,160 KB
testcase_04 AC 95 ms
12,288 KB
testcase_05 AC 91 ms
12,160 KB
testcase_06 AC 94 ms
12,288 KB
testcase_07 AC 105 ms
12,800 KB
testcase_08 AC 154 ms
16,128 KB
testcase_09 AC 218 ms
21,376 KB
testcase_10 AC 565 ms
42,240 KB
testcase_11 AC 586 ms
42,368 KB
testcase_12 AC 586 ms
49,920 KB
testcase_13 AC 593 ms
50,688 KB
testcase_14 AC 601 ms
51,584 KB
testcase_15 AC 617 ms
52,352 KB
testcase_16 AC 664 ms
57,088 KB
testcase_17 AC 90 ms
12,416 KB
testcase_18 AC 89 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = STDIN.gets.to_i
A = STDIN.read.strip.split.map(&:to_i)

if !(2 .. 500000).include? N
    STDERR.puts "invalid N"
    exit 1
end

if N != A.size
    STDERR.puts "invalid A size"
    exit 1
end

if !A.all?{|x| (0 ... (2 ** 63)).include? x}
    STDERR.puts "Invalid A value"
    exit 1
end

sum = A.inject(:+)

if !(0 ... (2 ** 63)).include? sum
    STDERR.puts "Invalid sum"
    exit 1
end

puts sum
0