atcoder#ABC289G. [ABC289G] Shopping in AtCoder store
[ABC289G] Shopping in AtCoder store
Score : points
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.
5 4
100 200 300 400 500
120 370 470 80
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 .
4 4
0 2 10 2
13 13 0 4
52 52 10 18
Two customers may have the same motivation. Also, two items may have the same value.
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
6280 5466 5382 7410 5454 8120 7290 11680 5870 3670 8950 7000 5620 4608 3655
5 5
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000
10000000000 10000000000 10000000000 10000000000 10000000000
Note that the gross sales may not fit into a -bit integer type.