結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
12,288 KB
testcase_01 AC 75 ms
12,160 KB
testcase_02 AC 77 ms
12,160 KB
testcase_03 AC 126 ms
18,560 KB
testcase_04 AC 83 ms
12,544 KB
testcase_05 AC 150 ms
20,992 KB
testcase_06 AC 129 ms
18,560 KB
testcase_07 AC 107 ms
15,872 KB
testcase_08 AC 101 ms
13,824 KB
testcase_09 AC 117 ms
16,896 KB
testcase_10 AC 153 ms
22,400 KB
testcase_11 AC 157 ms
23,040 KB
testcase_12 AC 131 ms
18,688 KB
testcase_13 AC 79 ms
12,288 KB
testcase_14 AC 81 ms
12,160 KB
testcase_15 AC 83 ms
12,288 KB
testcase_16 AC 82 ms
12,160 KB
testcase_17 AC 80 ms
12,288 KB
testcase_18 AC 192 ms
26,112 KB
testcase_19 AC 186 ms
25,344 KB
testcase_20 AC 192 ms
26,112 KB
testcase_21 AC 212 ms
27,904 KB
testcase_22 AC 185 ms
25,344 KB
testcase_23 AC 198 ms
28,032 KB
testcase_24 AC 194 ms
28,032 KB
testcase_25 AC 196 ms
27,904 KB
testcase_26 AC 202 ms
28,288 KB
testcase_27 AC 198 ms
27,904 KB
testcase_28 AC 77 ms
12,288 KB
testcase_29 AC 76 ms
12,288 KB
testcase_30 AC 77 ms
12,032 KB
testcase_31 AC 78 ms
12,160 KB
testcase_32 AC 76 ms
12,160 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