시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 52 | 17 | 16 | 35.556% |
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)
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:
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$.
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$.
번호 | 배점 | 제한 |
---|---|---|
1 | 11 | $x, y \leq 500$, $n \leq 12$ |
2 | 24 | $x, y \leq 500$, $n \leq 200$ |
3 | 9 | $y = 0$ |
4 | 10 | $b[i]=b[j]$ (for all $0 \leq i, j \leq n-1$) |
5 | 14 | $a[i]=b[i]$ (for all $0 \leq i \leq n-1$) |
6 | 32 | 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)