Mock Competition Marketing
Time limit1sMemory limit1024 MB
Choose a subset of the 6 ad types; scanning the auction sequence, buy each auction whose type is chosen while budget K allows, and maximize the number bought.
- Level
Medium7 of 10
- Topics
- Brute force, Greedy, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
MOLOCO is a company that matches advertisers with potential users through its high-performance ad platform.
Whenever an app has space available for an ad, the app asks the AdExchange platform to decide which ad to show. AdExchange then holds an auction, in which bidders such as MOLOCO bid for the chance to show their advertisement.
RUN wants to advertise its 2020 ICPC Mock Competition. They have asked MOLOCO to place the advertisement. RUN has a total of dollars and wants to display the ad in internal apps used by KAIST members. The ads in those apps are in one of six types, and the bidding price depends only on the type of ad. The first bidder to bid on the ad gets to show their ad.
AdExchange has already determined the costs of the six ad types and the auctions it will run today. In the -th auction, AdExchange runs an auction for an ad of type . AdExchange never runs two auctions at the same time; more specifically, auction cannot start until after auction ends.
MOLOCO bids during auctions using the following strategy. Before the auctions begin, RUN selects a set of ad types. During the -th auction, if the ad type of that auction is in RUN's set and RUN has enough money to bid on an ad of that type, MOLOCO submits a bid. Otherwise, it ignores the auction.
MOLOCO is very fast at bidding, so it is always the first bidder if it bids on the ad. Find the maximum number of ads MOLOCO can bid on if RUN selects the set of ad types optimally.
Input
The first line contains two space-separated integers and . ()
The next line contains 6 integers . is the cost for ad type . ()
The next line contains integers . is the ad type of the -th auction. ()
Output
Print the maximum number of ads MOLOCO can bid on.