結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー LeonardoneLeonardone
提出日時 2016-09-30 06:24:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 596 ms / 3,000 ms
コード長 402 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 58,368 KB
最終ジャッジ日時 2023-08-26 16:46:57
合計ジャッジ時間 5,981 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,236 KB
testcase_01 AC 77 ms
15,088 KB
testcase_02 AC 74 ms
15,140 KB
testcase_03 AC 77 ms
15,336 KB
testcase_04 AC 76 ms
15,092 KB
testcase_05 AC 76 ms
15,040 KB
testcase_06 AC 78 ms
15,328 KB
testcase_07 AC 88 ms
15,576 KB
testcase_08 AC 133 ms
19,992 KB
testcase_09 AC 191 ms
24,468 KB
testcase_10 AC 489 ms
41,220 KB
testcase_11 AC 492 ms
41,496 KB
testcase_12 AC 503 ms
41,904 KB
testcase_13 AC 511 ms
42,320 KB
testcase_14 AC 518 ms
42,296 KB
testcase_15 AC 539 ms
42,720 KB
testcase_16 AC 596 ms
58,368 KB
testcase_17 AC 80 ms
15,156 KB
testcase_18 AC 79 ms
15,096 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