Alice picks t in [a, b] to maximize the gap while Bob replies with k cards whose sum is closest to t.
Medium6Dynamic programmingGame theoryNo attempts yetTime limit5sMemory limit1024 MBAlice and Bob play a card game. There are n cards, and card i has the integer xi written on it. The game runs in this order.
Alice wants ∣t−u∣ to be as large as possible, and Bob wants it to be as small as possible.
Before the game starts, both players know n, k, a, b and the integer on every card. Both play optimally. In particular, Alice picks t knowing that Bob will then make ∣t−u∣ as small as possible for the announced t. If several values of t are equally good, Alice picks the smallest of them.
Find the value of t Alice picks, and the k cards Bob picks for that t.
The first line contains the integers n, k, a, b (1≤k≤n≤600, 0≤a≤b≤180000).
The second line contains the integers x1,…,xn (0≤xi≤300), where xi is written on card i.
On the first line, print the value of t Alice picks.
On the second line, print the numbers of the k cards Bob picks in increasing order. When several sets of k cards make ∣t−u∣ as small as possible, print the set whose increasing sequence of card numbers is lexicographically smallest.