Why my approach is wrong

take two multiset ms1 store maximum elements and ms2 store minimum elements ,their size differ by one for array of first k elements.
if upcoming element is greater than max of ms2 store in ms1 and else to ms2.
after insert two element we check the size ,if ms1 size ==ms2 size remove minimum element from ms1 to ms2 .if size of ms2>ms1 then remove maximum element from ms2 and insert in ms1.add and sub variable store the sum of max elements and sum of minimum elements respectively and store in the answer.

problem link-3 out 1in

submission link