Category: | Algorithms | Title: | Auction |
Description: | |||
Recently the auction house has introduced a new type of auction, the lowest price auction. In this new system, people compete for the lowest bid price, as opposed to what they did in the past. What an amazing thing! Now you could buy cool stuff with one penny. Your task is to write the software to automate this auction system. First the auctioneer puts an upper limit on bid price for each item. Only positive price less than or equal to this price limit is a valid bid. For example, if the price limit is 100, then 1 to 100, inclusive, are all valid bid prices. Bidder can not put more than one bid for the same price on a same item. However they can put many bids on a same item, as long as the prices are different. After all bids are set, the auctioneer chooses the winner according to the following rules: 1. If any valid price comes from only one bidder, the price is a "unique bid". If there are unique bids, then the unique bid with the lowest price wins. This price is the winning price and the only bidder is the winning bidder. 2. If there are no unique bids, then the price with fewest bids is the winning bid. If there are more than one price which has the same lowest bid count, choose the lowest one. This price is the winning price. The bidder who puts this bid first is the winning bidder. Given the price limit and all the bids that happen in order, you will determine the winning bidder and the winning price. Input Description The first line of each test case contains two integers: U (1 <= U <= 10,000), the price upper limit and M (1 <= M <= 100,000), the total number of bids. M lines follow, each of which presents a single bid. The bid contains the bidder's name (consecutive non-whitespace characters) and the price P (1 <= P <= U), separated with a single space. All bids in the input are guaranteed to be valid ones. Output Description For each test case, print the sentence "The winner is W." on the first line, and "The price is P." on the second. Replace W and P with the winning bidder’s name and the winning price. | |||
Examples: | |||
Sample Input 3 3 Alice 1 Bob 2 Carl 3 3 6 Alice 1 Alice 2 Alice 3 Bob 1 Bob 3 Carl 3 Sample Output Case 1: The winner is Alice. The | |||
Time Limitation: | 2 s | Memory Limitation: | 32 MB |
Score: | 50 Points | Language: |
网络资源的拷贝粘贴 备份参考之用
6 April 2007
Auction [算法题]
Subscribe to:
Post Comments (Atom)
-
{
New Yorker
(11)
}
{
fiction
(11)
}
{
Programming
(9)
}
{
people
(7)
}
{
Google
(6)
}
{
algorithm
(5)
}
{
Internet
(4)
}
{
MIT Media Lab
(4)
}
{
photo
(4)
}
{
picture
(4)
}
{
United States presidential election 2008
(3)
}
{
book
(3)
}
{
冯象
(3)
}
{
电影
(3)
}
{
Erik Demaine
(2)
}
{
Information Retrieval
(2)
}
{
Neil Gaiman
(2)
}
{
Power Law
(2)
}
{
Steve_Jobs
(2)
}
{
movie
(2)
}
{
典故
(2)
}
{
思维的乐趣
(2)
}
{
Art
(1)
}
{
Auto Summarization
(1)
}
{
Barack Hussein Obama
(1)
}
{
Classical Music
(1)
}
{
French
(1)
}
{
Gallery
(1)
}
{
Google Video
(1)
}
{
HARUKI MURAKAMI
(1)
}
{
Hilary Clinton
(1)
}
{
Javascript
(1)
}
{
Psychology
(1)
}
{
cheat sheet
(1)
}
{
data structure
(1)
}
{
foosball
(1)
}
{
lyrics
(1)
}
{
movie making
(1)
}
{
music
(1)
}
{
poem
(1)
}
{
ranking
(1)
}
{
wikipedia
(1)
}
{
三联生活周刊
(1)
}
{
拍电影
(1)
}
{
数学之美系列
(1)
}
{
村上春树
(1)
}
{
算法
(1)
}
{
美术馆
(1)
}
No comments:
Post a Comment