結果

問題 No.1564 Sum of Products of Pairs
ユーザー 小野寺健小野寺健
提出日時 2021-11-12 18:23:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 131 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 28,160 KB
最終ジャッジ日時 2024-05-04 01:14:04
合計ジャッジ時間 7,181 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
12,416 KB
testcase_01 AC 78 ms
12,160 KB
testcase_02 AC 79 ms
12,288 KB
testcase_03 AC 132 ms
18,560 KB
testcase_04 AC 84 ms
12,672 KB
testcase_05 AC 148 ms
20,864 KB
testcase_06 AC 130 ms
18,304 KB
testcase_07 AC 106 ms
16,000 KB
testcase_08 AC 93 ms
13,952 KB
testcase_09 AC 113 ms
16,768 KB
testcase_10 AC 155 ms
22,144 KB
testcase_11 AC 167 ms
23,296 KB
testcase_12 AC 140 ms
18,944 KB
testcase_13 AC 77 ms
12,416 KB
testcase_14 AC 80 ms
12,288 KB
testcase_15 AC 79 ms
12,160 KB
testcase_16 AC 111 ms
12,288 KB
testcase_17 AC 99 ms
12,160 KB
testcase_18 AC 186 ms
26,112 KB
testcase_19 AC 180 ms
25,472 KB
testcase_20 AC 187 ms
26,240 KB
testcase_21 AC 189 ms
27,904 KB
testcase_22 AC 187 ms
25,472 KB
testcase_23 AC 189 ms
28,032 KB
testcase_24 AC 194 ms
27,904 KB
testcase_25 AC 192 ms
27,904 KB
testcase_26 AC 194 ms
28,160 KB
testcase_27 AC 191 ms
27,904 KB
testcase_28 AC 76 ms
12,288 KB
testcase_29 AC 79 ms
12,160 KB
testcase_30 AC 76 ms
12,160 KB
testcase_31 AC 80 ms
12,160 KB
testcase_32 AC 74 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
a = gets.split(" ").map{|s| s.to_i}

a.sort!.reverse!

sum = 0
0.upto(N-1) {|i|
	sum += a[2*i] * a[2*i+1]
}

puts sum
0