結果

問題 No.6 使いものにならないハッシュ
ユーザー LaLa
提出日時 2020-12-20 12:15:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 292 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 11,124 KB
実行使用メモリ 16,824 KB
最終ジャッジ日時 2023-10-14 23:28:35
合計ジャッジ時間 6,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
15,328 KB
testcase_01 AC 96 ms
15,152 KB
testcase_02 AC 148 ms
16,824 KB
testcase_03 AC 108 ms
15,360 KB
testcase_04 AC 118 ms
15,636 KB
testcase_05 AC 119 ms
15,592 KB
testcase_06 AC 140 ms
16,188 KB
testcase_07 AC 134 ms
15,876 KB
testcase_08 AC 140 ms
15,968 KB
testcase_09 AC 134 ms
15,884 KB
testcase_10 AC 96 ms
15,148 KB
testcase_11 AC 108 ms
15,560 KB
testcase_12 AC 139 ms
16,368 KB
testcase_13 AC 135 ms
15,880 KB
testcase_14 AC 135 ms
16,020 KB
testcase_15 AC 140 ms
16,212 KB
testcase_16 AC 135 ms
15,836 KB
testcase_17 AC 141 ms
16,564 KB
testcase_18 AC 148 ms
16,732 KB
testcase_19 AC 140 ms
16,452 KB
testcase_20 AC 140 ms
16,472 KB
testcase_21 AC 104 ms
15,480 KB
testcase_22 AC 141 ms
16,540 KB
testcase_23 AC 139 ms
16,256 KB
testcase_24 AC 140 ms
16,528 KB
testcase_25 AC 135 ms
16,052 KB
testcase_26 AC 144 ms
16,544 KB
testcase_27 AC 141 ms
16,284 KB
testcase_28 AC 121 ms
15,832 KB
testcase_29 AC 145 ms
16,452 KB
testcase_30 AC 145 ms
16,576 KB
testcase_31 AC 139 ms
16,432 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'
K=gets.to_i
N=gets.to_i

primes=Prime.each(N).select{|prime|K<=prime}.map{|i|[i,i%9]}

A=[]
cnt=[0]*10
max=0
ans=0

primes.each{|i,j|
    A<<[i,j]
    cnt[j]+=1
    cnt[A.shift[1]]-=1 while cnt[j]>1
    if max<=A.size
        max=A.size
        ans=A[0][0]
    end
}

puts ans
0