結果

問題 No.1233 割り切れない気持ち
ユーザー simansiman
提出日時 2020-10-20 10:23:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 508 ms / 3,153 ms
コード長 317 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 11,184 KB
実行使用メモリ 31,164 KB
最終ジャッジ日時 2023-09-28 13:37:02
合計ジャッジ時間 18,347 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,172 KB
testcase_01 AC 80 ms
15,248 KB
testcase_02 AC 81 ms
15,220 KB
testcase_03 AC 84 ms
15,148 KB
testcase_04 AC 87 ms
15,152 KB
testcase_05 AC 81 ms
15,064 KB
testcase_06 AC 82 ms
15,248 KB
testcase_07 AC 180 ms
19,180 KB
testcase_08 AC 252 ms
22,284 KB
testcase_09 AC 424 ms
27,976 KB
testcase_10 AC 444 ms
28,896 KB
testcase_11 AC 167 ms
18,812 KB
testcase_12 AC 505 ms
30,828 KB
testcase_13 AC 505 ms
31,112 KB
testcase_14 AC 502 ms
31,076 KB
testcase_15 AC 502 ms
30,952 KB
testcase_16 AC 508 ms
31,072 KB
testcase_17 AC 183 ms
27,068 KB
testcase_18 AC 492 ms
30,960 KB
testcase_19 AC 491 ms
31,164 KB
testcase_20 AC 183 ms
26,840 KB
testcase_21 AC 186 ms
27,352 KB
testcase_22 AC 190 ms
27,420 KB
testcase_23 AC 188 ms
27,344 KB
testcase_24 AC 192 ms
27,420 KB
testcase_25 AC 189 ms
27,336 KB
testcase_26 AC 189 ms
27,440 KB
testcase_27 AC 487 ms
30,612 KB
testcase_28 AC 483 ms
30,468 KB
testcase_29 AC 481 ms
30,620 KB
testcase_30 AC 486 ms
30,616 KB
testcase_31 AC 487 ms
30,836 KB
testcase_32 AC 489 ms
30,832 KB
testcase_33 AC 499 ms
30,476 KB
testcase_34 AC 491 ms
30,600 KB
testcase_35 AC 491 ms
30,836 KB
testcase_36 AC 486 ms
30,548 KB
testcase_37 AC 80 ms
15,128 KB
testcase_38 AC 479 ms
30,040 KB
testcase_39 AC 486 ms
30,396 KB
testcase_40 AC 481 ms
30,688 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

1.upto(M) 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