更新日時で差をつけろ

むしろ差をつけられている

JOI 難易度5: Common Sub-String

共通部分文字列 | Aizu Online Judge わかんないよ〜〜〜

# 非公式の)解説を見た。。。。が解けねぇ!
# see: http://d.hatena.ne.jp/jetbead/20110724/1311526610

lines = STDIN.read.split

lines.each_slice(2) do |a, b|
  s, t = [a, b].sort { |x, y| y.size - x.size }.map(&:chomp)
  f = "-" * (t.size-1)
  s = f + s

  ans = 0
  (s.size-t.size).times do |offset|
    lens = [0]
    t.chars.each_with_index do |tch, ti|
      if tch == s[offset+ti]
        lens[-1] += 1
      else
        lens << 0 unless lens[-1] == 0
      end
    end
    ans = [ans, lens.max].max
  end

  puts ans
end