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

27548번 - Zrinka 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB56342860.870%

문제

You are given two arrays of length $n$ and $m$ respectively, which consist only of 0ドル$’s and 1ドル$’s.

Your task is to replace every zero with an even positive integer and every one with an odd positive integer. After replacements both arrays should be increasing and you can use each postive integers at most once.

As this would be to easy, you are asked to do it such that the largest number you use is as small as possible.

Given two arrays, output the minimum possible largest number that needs to be used.

입력

The first array is of length $n$ (0ドル ≤ n ≤ 5,000円$), the second is of length $m$ (1ドル ≤ m ≤ 5,000円$).

The first line consists of $n + 1$ integers, first being $n,ドル and others describing the first array.

The second line consists of $m + 1$ integers, first being $m,ドル and others describing the second array.

출력

The first and only line should contain a positive integer, the answer to the question above.

제한

서브태스크

번호배점제한
115

$n = 0$

220

The first array consists only of 0ドル$’s.

315

$n, m ≤ 500$

420

No additional constraints.

예제 입력 1

0
4 1 0 1 1

예제 출력 1

5

예제 입력 2

4 0 1 0 1
4 1 0 0 1

예제 출력 2

9

예제 입력 3

5 0 1 0 0 1
4 0 0 0 1

예제 출력 3

13

힌트

Clarification of the second example: One of the possible solutions is $(2, 3, 4, 5)$ and $(1, 6, 8, 9)$.

Clarification of the third example: One of the possible solutions is $(2, 3, 6, 8, 9)$ and $(4, 10, 12, 13)$.

출처

Contest > Croatian Open Competition in Informatics > COCI 2022/2023 > Contest #4 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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