当前位置: 代码迷 >> 综合 >> ???Auction Bidding
  详细解决方案

???Auction Bidding

热度:28   发布时间:2023-11-03 00:58:22.0

Company ABC is holding an antique auction. In the auction, there are NN1 \leq N \leq 10001N1000, lots. We number the lots from 11 to NN. There are MM1 \leq M \leq 5001M500, bidders participated in the auction. We number the bidders from 11 to MM. The winning bid for each lot is determined by the following rules:

? Each lot has a reserved price, which is a positive integer.

? Each bidder may submit at most one bid to each lot whose amount must be a positive integer.

? A valid bid for a lot is one that is at least the reserved price for the lot. All invalid bids are not considered.

? The largest valid bid wins the lot and is called the winning bid. In case of tie bids, the bidder with the smaller bidder number wins. If there is no valid bid for a lot, then this lot is not sold.

? The second largest bid is a valid bid that does not win if one exists; otherwise, it is the reserved price.

? If a bidder wins a lot, then the final hammer price for this lot is either 10\%10% over the second largest bid or the largest valid bid, depending on which one is smaller. If the final hammer price is not an integer, then it is truncated to the nearest integer.

? Given the reserved price and the bids for each lot, your task is to decide the total final hammer prices for a given k, 0 < k \leq M0<kM, bidders.

Input Format

The input contains N + 3 + kN+3+k lines.

Line 11NN

Line 22MM

Line 33r_{1}, b_{1,1}, p_{1,1}, b_{1,2}, p{1,2}, -1r?1??,b?1,1??,p?1,1??,b?1,2??,p1,2,?1

\ldots

Line i + 2i+2r_{i}, b_{i,1}, p_{i,1}, b_{i,2}, p{i,2}, -1r?i??,b?i,1??,p?i,1??,b?i,2??,pi,2,?1

\ldots

Line N + 2N+2r_{N}, b_{N,1}, p_{N,1}, b_{N,2}, p_{N,2}, -1r?N??,b?N,1??,p?N,1??,b?N,2??,p?N,2??,?1

Line N + 3N+3kk

Line N + 4N+4q_{1}q?1??

\ldots

Line N + 3 + iN+3+iq_{i}q?i??

\ldots

Line N + 3 + kN+3+kq_{k}q?k??

In Line i + 2i+2r_{i}r?i?? is the reserved price for lot ii. The number b_{i,j}b?i,j?? and p{i,j}pi,j are the j^{th}j?th?? bid for lot ii from bidder b_{i,j}b?i,j??with the amount p_{i,j}p?i,j?? . Note that a space is between each number. The number -1?1 is added to mark the end of bids for a lot. In Line N+3N+3kk is given. In line N + 3 + iN+3+i, you are asked to provide the total hammer prices for bidder q_{i}q?i??.

Output Format:

The output contains kk lines.

Line 11h_{1}h?1??

\ldots

Line iih_{i}h?i??

\ldots

Line kkh_{k}h?k??

The total hammer prices for bidder q_{i}q?i?? is h_{i}h?i??.

Hint

In the sample, the bidder 11 got the the first lot 11 at hammer price 1313.

样例输入

3
3
11 2 12 1 15 -1
5 3 4 -1
23 1 32 2 35 3 40 -1
1
1

样例输出

13

题目来源

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛