#abc289g. G - Shopping in AtCoder store
G - Shopping in AtCoder store
Score : points
问题描述
高桥经营着一家 AtCoder 商店。有 名顾客光顾这家商店,并且店里出售 件商品。第 位()顾客的购买意愿为 ,而第 件()商品的价值为 。
高桥为每件商品设定一个价格。第 位顾客会购买第 件商品,当且仅当其价格 满足以下条件:
- 。
对于每个 ,在高桥设定价格以最大化销售额的情况下,找出第 件商品的总销售额。第 件商品的总销售额定义为 与购买该商品的顾客数量的乘积。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi runs AtCoder store. customers visit the store, and items are sold in the store. The motivation of the -th customer is . The value of the -th item is .
Takahashi sets a price for each item. The -th customer buys one -th item if and only if its price satisfies:
- .
For each , find the gross sale of the -th item when Takahashi sets the price so that the sale is maximized. The gross sale of the -th item is defined as the product of and the number of customers that buys the -th item.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print a line containing the gross sale of the -th item for each , separated by spaces.
Sample Input 1
5 4
100 200 300 400 500
120 370 470 80
Sample Output 1
1280 2350 2850 1140
For example, he may set the price of the -st item to ; then the -nd, -rd, -th, and -th customers will buy one. The gross sale of the -st item will be . Since he cannot make the gross sale of the -st item greater than , the -st value to be printed is .
Sample Input 2
4 4
0 2 10 2
13 13 0 4
Sample Output 2
52 52 10 18
Two customers may have the same motivation. Also, two items may have the same value.
Sample Input 3
12 15
16 592 222 983 729 338 747 61 451 815 838 281
406 319 305 519 317 590 507 946 365 5 673 478 340 176 2
Sample Output 3
6280 5466 5382 7410 5454 8120 7290 11680 5870 3670 8950 7000 5620 4608 3655
Sample Input 4
5 5
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000
Sample Output 4
10000000000 10000000000 10000000000 10000000000 10000000000
Note that the gross sales may not fit into a -bit integer type.
update @ 2024/3/10 12:05:32