結果

問題 No.2203 POWER!!!!!
ユーザー simansiman
提出日時 2023-02-05 21:15:52
言語 Ruby
(3.3.0)
結果
AC  
実行時間 307 ms / 2,000 ms
コード長 212 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,532 KB
実行使用メモリ 30,016 KB
最終ジャッジ日時 2023-09-17 11:13:23
合計ジャッジ時間 3,934 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,216 KB
testcase_01 AC 81 ms
15,212 KB
testcase_02 AC 81 ms
15,232 KB
testcase_03 AC 82 ms
15,000 KB
testcase_04 AC 81 ms
15,256 KB
testcase_05 AC 81 ms
15,264 KB
testcase_06 AC 81 ms
15,260 KB
testcase_07 AC 82 ms
15,044 KB
testcase_08 AC 113 ms
16,632 KB
testcase_09 AC 170 ms
20,136 KB
testcase_10 AC 236 ms
23,728 KB
testcase_11 AC 307 ms
27,680 KB
testcase_12 AC 113 ms
16,828 KB
testcase_13 AC 202 ms
30,012 KB
testcase_14 AC 201 ms
29,824 KB
testcase_15 AC 203 ms
29,804 KB
testcase_16 AC 202 ms
29,868 KB
testcase_17 AC 199 ms
30,016 KB
testcase_18 AC 81 ms
15,152 KB
testcase_19 AC 80 ms
15,064 KB
testcase_20 AC 79 ms
15,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i).sort

memo = Hash.new
ans = 0

A.each do |a|
  if !memo[a]
    v = 0

    A.each do |b|
      v += a.pow(b)
    end

    memo[a] = v
  end

  ans += memo[a]
end

puts ans
0