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

6230번 - Buy One Get One Free 다국어

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

문제

Farmer John has discovered the Internet is buying bales of hay online when he notices a special deal. For every bale of hay of size A (1 <= A <= 1,000,000) he buys, he can get a bale of hay of size B (1 <= B < A) for free!

The deal, however, is restricted: the larger bale must be high quality hay and the smaller one must be low quality hay. FJ, being a frugal and thrifty fellow, does not care: any quality of hay will do as long as he saves some money.

Given a list of the sizes of N (1 <= N <= 10,000) bales of high quality hay and M (1 <= M <= 10,000) bales of low quality hay, find the maximum number of bales of hay Farmer John can purchase. He can buy bales of high quality hay without getting the free bale of low quality hay, but he cannot buy bales of low quality hay (i.e., he must get them for free in the deal).

입력

  • Line 1: Two space-separated integers: N and M.
  • Lines 2..N+1: Line i+1 contains a single integer which is the size of the ith bale of high quality hay.
  • Lines N+2..N+M+1: Line i+N+1 contains a single integer which is the size of the ith bale of low quality hay.

출력

  • Line 1: The maximum total number of bales of hay Farmer John can obtain.

제한

예제 입력 1

3 4
6
1
3
1
5
3
4

예제 출력 1

5

힌트

Obviously, Farmer John can buy all the bales of high quality hay. When he buys the size 6 high quality bale, he can get any low quality bale for free (say, the bale of size 3). When he buys the size 3 high quality bale, he can get the size 1 low quality bale for free. When he buys the size 1 high quality bale, however, he cannot get any low quality bales for free (since the size must be strictly less). The total, no matter how clever FJ is, comes to five bales.

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO February 2007 Contest > Bronze 3번

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

출처

대학교 대회

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

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