Logo
(追記) (追記ここまで)

6042번 - Longest Contiguous Subsequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB118867774.038%

문제

Bessie's friend Jessie wanted to enter a programming contest. "What are the tasks like?" she asked.

Bessie, known to be knowledgeable about so many things, said "Here is a typical problem that folks solve early in their competitive career. See if you can solve it."

Perhaps you can solve it, too.

You are given two sequences of integers, S1 and S2. S1 has length L1 (1 <= L1 <= 180) and S2 has length L2 (1 <= L2 <= 180). Your job is to print out the length of the longest contiguous subsequence of numbers common to both S1 and S2. Ordered sequence S1 has elements S1_1, S1_2, ..., S1_L1 (-100 <= S1_i <= 100); S2 has elements S2_i (-100 <= S2_i <= 100).

A contiguous subsequence is a consecutive run of numbers in that sequence. The subsequences of 1 2 3 1 are: the empty sequence, "1", "1 2", "1 2 3", "1 2 3 1", "2", "2 3", "2 3 1", "3", "3 1", and a repeat occurrence of "1".

입력

  • Line 1: Two space-separated integers: L1 and L2
  • Lines 2..L1+1: Line i+1 contains a single integer: S1_i
  • Lines L1+2..L1+L2+1: Line L1+i+1 contains a integer: S2_i

출력

  • Line 1: A single integer, the length of the longest contiguous subsequence of S1 and S2

제한

예제 입력 1

10 12
1
1
1
3
2
3
3
3
4
5
1
1
1
1
3
2
3
3
4
4
5
-8

예제 출력 1

7

힌트

Corresponds to the contiguous subsequence 1,1,1,3,2,3,3.

출처

Olympiad > USA Computing Olympiad > 2009-2010 Season > USACO March 2010 Contest > Bronze 4번

Olympiad > USA Computing Olympiad > 2009-2010 Season > USACO Holiday Bonus 2010 Contest > Gold 1번

  • 문제의 오타를 찾은 사람: kcm1700
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /