#P16550. [ICPC 2026 LAC] Dropshipping

[ICPC 2026 LAC] Dropshipping

题目描述

Drew P. Shipper received NN customer requests for products sold at a store called EvenBuy, where all product prices are even integers. To fulfill the ii-th request, Drew must purchase a specific product that costs AiA_i at EvenBuy, and Drew has already charged this price to the customer.

Drew is doing this for profit, based on a loyalty program that EvenBuy has: after Drew makes XX full-price purchases, he gets a discount of 50%50\% in his next single purchase. This discounted purchase does not count toward the XX full-price purchases required to earn the next discount. Because Drew’s customers paid him the full price upfront, he keeps the amount of the discount as his own profit whenever he purchases a discounted item.

Drew can decide the order of his purchases at EvenBuy to maximize his total profit. However, delivery times are directly related to the order of the purchases, and to avoid customer complaints, he cannot delay a purchase too much. In practice, Drew must fulfill the ii-th request within his first i+Ki+K purchases at EvenBuy.

Your task is to find the maximum total profit Drew can achieve. Each purchase fulfills exactly one request and each request must be fulfilled exactly once.

输入格式

The first line contains three integers NN, XX (1N,X2×1051 \le N, X \le 2 \times 10^5) and KK (0K2×1050 \le K \le 2 \times 10^5), indicating respectively the number of customer requests, the number of full-price purchases required to get a 50% discount, and the delivery limit (the ii-th request must be fulfilled within the first i+Ki + K purchases).

The second line contains NN even integers A1,A2,,ANA_1, A_2, \ldots, A_N (2Ai1092 \le A_i \le 10^9), representing the prices of the requested products.

输出格式

Output a single line with an integer indicating the maximum total profit Drew can achieve.

3 1 0
6 4 14
2
3 1 1
6 4 14
7

提示

Explanation of Sample 1:

Since K=0K=0, the ii-th request must be fulfilled with the ii-th purchase. As only the second purchase is discounted, Drew can only achieve a profit of 4/2=24/2 = 2.

Explanation of Sample 2:

Now the ii-th request must be fulfilled within the first i+1i + 1 purchases. So the valid purchase orders are [6,4,14][6, 4, 14], [6,14,4][6, 14, 4], [4,6,14][4, 6, 14] and [14,6,4][14, 6, 4]. The order [6,14,4][6, 14, 4] is the best, as Drew can achieve a profit of 14/2=714/2 = 7 on the second purchase.