結果

問題 No.430 文字列検索
ユーザー neko_the_shadowneko_the_shadow
提出日時 2016-10-03 00:51:45
言語 Ruby
(3.3.0)
結果
AC  
実行時間 889 ms / 2,000 ms
コード長 220 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 11,320 KB
実行使用メモリ 15,552 KB
最終ジャッジ日時 2023-08-27 02:09:24
合計ジャッジ時間 8,422 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
15,236 KB
testcase_01 AC 234 ms
15,308 KB
testcase_02 AC 449 ms
15,300 KB
testcase_03 AC 407 ms
15,324 KB
testcase_04 AC 72 ms
15,280 KB
testcase_05 AC 70 ms
15,188 KB
testcase_06 AC 67 ms
15,240 KB
testcase_07 AC 69 ms
15,112 KB
testcase_08 AC 67 ms
15,140 KB
testcase_09 AC 69 ms
15,144 KB
testcase_10 AC 71 ms
15,256 KB
testcase_11 AC 825 ms
15,368 KB
testcase_12 AC 836 ms
15,180 KB
testcase_13 AC 866 ms
15,256 KB
testcase_14 AC 889 ms
15,340 KB
testcase_15 AC 865 ms
15,552 KB
testcase_16 AC 732 ms
15,088 KB
testcase_17 AC 726 ms
15,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

def f(base, token)
  i = cnt = 0
  while i = base.index(token, i) 
    i += 1
    cnt += 1
  end
  cnt
end

base = gets.chomp
m = gets.to_i
tokens = $<.map(&:chomp)

p tokens.reduce(0){|sum, token| sum + f(base, token)}
0