Professional Documents
Culture Documents
Gambling Assistant (Gamble) : OIS2017 - Round 2
Gambling Assistant (Gamble) : OIS2017 - Round 2
; + + S
OIS2017 Round 2
Online, November 28th 2016
gamble EN
Among the attachments of this task you may find a template file gamble.* with a sample
incomplete implementation.
Input
The first line contains the two integers N and K. The second line contains N integers Ci .
Output
You need to write a single line with N integers Gi , the highest grand total possible when drawing the
given cards.
gamble
Page 1 of 2
O I ( )
; + + S
OIS2017 Round 2
gamble EN
Constraints
1 K N 100 000 000.
1 Ci 13 for each i = 0 . . . N 1.
Scoring
Your program will be tested against several test cases grouped in subtasks. In order to obtain the score
of a subtask, your program needs to correctly solve all of its test cases.
Subtask 1 [ 5 points]: Examples.
Subtask 2 [10 points]: N = K.
Subtask 3 [10 points]: K = 1.
Subtask 4 [30 points]: N 100.
Subtask 5 [25 points]: N 10 000.
Subtask 6 [20 points]: No additional limitations.
Examples
input.txt
output.txt
4 2
10 4 10 12
10 14 20 22
8 5
4 13 10 2 7 1 13 7
4 17 27 29 36 36 47 50
Explanation
In the first sample case, the hands kept by the player (in order) are:
[4] [4, 13] [4, 10, 13] [2, 4, 10, 13] [2, 4, 7, 10, 13]
[2, 4, 7, 10, 13] [4, 7, 10, 13, 13] [7, 7, 10, 13, 13].
gamble
Page 2 of 2