結果

問題 No.1233 割り切れない気持ち
ユーザー simansiman
提出日時 2020-10-20 11:21:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 530 ms / 3,153 ms
コード長 398 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 39,160 KB
最終ジャッジ日時 2023-09-28 13:39:04
合計ジャッジ時間 12,458 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,068 KB
testcase_01 AC 85 ms
15,300 KB
testcase_02 AC 84 ms
15,124 KB
testcase_03 AC 87 ms
15,216 KB
testcase_04 AC 86 ms
15,164 KB
testcase_05 AC 84 ms
15,124 KB
testcase_06 AC 84 ms
15,156 KB
testcase_07 AC 169 ms
20,516 KB
testcase_08 AC 227 ms
24,852 KB
testcase_09 AC 381 ms
33,256 KB
testcase_10 AC 394 ms
34,396 KB
testcase_11 AC 151 ms
20,236 KB
testcase_12 AC 458 ms
36,888 KB
testcase_13 AC 450 ms
36,720 KB
testcase_14 AC 455 ms
36,860 KB
testcase_15 AC 469 ms
36,932 KB
testcase_16 AC 466 ms
36,788 KB
testcase_17 AC 197 ms
28,812 KB
testcase_18 AC 530 ms
39,160 KB
testcase_19 AC 227 ms
33,064 KB
testcase_20 AC 195 ms
28,808 KB
testcase_21 AC 203 ms
29,428 KB
testcase_22 AC 199 ms
29,588 KB
testcase_23 AC 198 ms
29,520 KB
testcase_24 AC 197 ms
29,480 KB
testcase_25 AC 197 ms
29,464 KB
testcase_26 AC 196 ms
29,472 KB
testcase_27 AC 223 ms
32,644 KB
testcase_28 AC 223 ms
32,560 KB
testcase_29 AC 222 ms
32,744 KB
testcase_30 AC 222 ms
32,700 KB
testcase_31 AC 223 ms
32,572 KB
testcase_32 AC 223 ms
32,528 KB
testcase_33 AC 224 ms
32,500 KB
testcase_34 AC 222 ms
32,508 KB
testcase_35 AC 222 ms
32,640 KB
testcase_36 AC 228 ms
32,680 KB
testcase_37 AC 86 ms
15,244 KB
testcase_38 AC 236 ms
31,964 KB
testcase_39 AC 387 ms
35,492 KB
testcase_40 AC 380 ms
35,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
M = A.max
C = Array.new(M + 1, 0)
D = Array.new(M + 1, 0)

ans = 0

A.each do |a|
  C[a] += 1
  ans += a
end

ans *= N

M.downto(1) do |i|
  C[i - 1] += C[i]
end

=begin
1.upto(M) do |i|
  i.step(M, i) do |j|
    D[i] += C[j]
  end
end
=end

A.uniq.each do |i|
  i.step(M, i) do |j|
    D[i] += C[j]
  end
end

A.each do |a|
  ans -= D[a] * a
end

puts ans
0