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

19930번 - Jelly Flavours 서브태스크다국어언어 제한함수 구현

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

문제

Amy is a big fan of jelly, and wishes to buy some for dessert. There are a total of $n$ flavours of jelly, numbered 0ドル$ to $n-1$. Store A sells jelly of flavour $i$ for $a[i]$ dollars a piece, whereas Store B sells it for $b[i]$ dollars a piece. Amy can spend up to $x$ dollars in Store A and up to $y$ dollars in Store B.

Help Amy find the maximum number of unique flavours of jelly she can purchase.

구현

You should implement the following procedure:

int find_maximum_unique(int x, int y, int[] a, int[] b)
  • $x$: amount of money that can be spent in Store A.
  • $y$: amount of money that can be spent in Store B.
  • $a$: an array of length $n,ドル containing the cost of each jelly in Store A.
  • $b$: an array of length $n,ドル containing the cost of each jelly in Store B.
  • This procedure will be called exactly once.
  • The procedure should return the maximum number of unique flavours of jelly Amy can purchase.

제한

  • 1ドル \leq n \leq 2000$
  • 0ドル \leq x, y \leq 10\;000$
  • 0ドル \leq a[i], b[i] \leq 10\;000$ (for all 0ドル \leq i \leq n-1$)

예시 1

Consider the following call:

find_maximum_unique(2, 3, [2, 1, 4], [2, 3, 2])

This means that Amy can spend up to 2ドル$ dollars in Store A and 3ドル$ dollars in Store B, and the prices are as follows:

  • Jelly 0ドル$ costs 2ドル$ dollars in both Store A and B,
  • Jelly 1ドル$ costs 1ドル$ dollar in Store A and 3ドル$ dollars in Store B,
  • Jelly 2ドル$ costs 4ドル$ dollars in Store A and 2ドル$ dollars in Store B.

The maximum number of unique flavours Amy can purchase is 2ドル$. This can be done by buying jelly 0ドル$ from Store A and jelly 2ドル$ from Store B for 2ドル$ dollars each.

Therefore, the procedure should return 2ドル$.

예시 2

Consider the following call:

find_maximum_unique(6, 12, [5, 1, 5, 6, 3], [3, 5, 4, 6, 7])

In this case, the maximum number of unique flavours Amy can purchase is 4ドル$. This can be done by purchasing jellies 1ドル$ and 2ドル$ from Store A, costing 1ドル+5=6$ dollars, as well as jellies 0ドル$ and 4ドル$ from Store B, costing 3ドル+7=10$ dollars.

Therefore, the procedure should return 4ドル$.

서브태스크

번호배점제한
111

$x, y \leq 500,ドル $n \leq 12$

224

$x, y \leq 500,ドル $n \leq 200$

39

$y = 0$

410

$b[i]=b[j]$ (for all 0ドル \leq i, j \leq n-1$)

514

$a[i]=b[i]$ (for all 0ドル \leq i \leq n-1$)

632

No additional constraints.

힌트

첨부

출처

Olympiad > International Olympiad in Informatics > IOI 2021 > Practice 2번

Olympiad > International Olympiad in Informatics > IOI 2020 > Practice 2번

제출할 수 있는 언어

C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)

채점 및 기타 정보

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

출처

대학교 대회

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

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