### use_me's blog

By use_me, history, 4 days ago, ,

Given N elements perform the following operation any number of times. Chose exactly k numbers Put all the selected numbers in the bag. if any of the selected number was already in the bag remove it from he bag. Do the operation any number of times to maximise the sum of all he numbers in the bag.

For eg : n = 5, k = 3; n elements are : 7 5 3 2 2 here we can chose

1.) 7 5 3 which makes the sum 7+5+3 = 15;

2.) 7 5 2 which makes the sum 15-7-5+2 = 5;

3.) 7 5 2 which makes the sum 5+7+5+2 = 19;

output : 19

eg 2 :

n = 9, k = 5; n elements are -1 2 3 4 5 6 7 8 9

1.) -1 2 3 4 5

2.) -1 6 7 8 9

output : 44

• -13

 » 4 days ago, # |   0 Auto comment: topic has been updated by use_me (previous revision, new revision, compare).
 » 4 days ago, # |   0 Auto comment: topic has been updated by use_me (previous revision, new revision, compare).
 » 4 days ago, # |   +1 https://www.codechef.com/JUNE19A/problems/LENTMO Seems like it's from an ongoing contest. If you can't solve it editorials will be posted after 17th.