結果

問題 No.118 門松列(2)
ユーザー simansiman
提出日時 2015-01-07 02:32:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 328 ms / 5,000 ms
コード長 307 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 21,120 KB
最終ジャッジ日時 2024-04-17 12:50:16
合計ジャッジ時間 8,250 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
12,800 KB
testcase_01 AC 328 ms
20,992 KB
testcase_02 AC 321 ms
20,736 KB
testcase_03 AC 321 ms
20,864 KB
testcase_04 AC 326 ms
21,120 KB
testcase_05 AC 322 ms
20,864 KB
testcase_06 AC 211 ms
12,416 KB
testcase_07 AC 212 ms
12,288 KB
testcase_08 AC 210 ms
12,416 KB
testcase_09 AC 315 ms
20,352 KB
testcase_10 AC 233 ms
13,312 KB
testcase_11 AC 240 ms
14,336 KB
testcase_12 AC 223 ms
13,184 KB
testcase_13 AC 221 ms
12,672 KB
testcase_14 AC 313 ms
20,224 KB
testcase_15 AC 213 ms
12,672 KB
testcase_16 AC 269 ms
15,616 KB
testcase_17 AC 220 ms
12,800 KB
testcase_18 AC 240 ms
14,208 KB
testcase_19 AC 255 ms
15,488 KB
testcase_20 AC 263 ms
15,360 KB
testcase_21 AC 293 ms
17,792 KB
testcase_22 AC 232 ms
13,440 KB
testcase_23 AC 284 ms
18,304 KB
testcase_24 AC 242 ms
14,720 KB
testcase_25 AC 258 ms
15,360 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

class A
  def initialize
    n = gets.chomp.to_i
    a = gets.chomp.split(' ').map(&:to_i)

    count = 0

    cache = Hash.new(false)

    [*(1..100)].combination(3) do |list|
      count += list.map{|i| cache[i] || cache[i] = a.count(i)}.inject(:*)
    end

    puts count % (10 ** 9 + 7)
  end
end

A.new
0