function solution(k, score) {
var answer = [];
let array = []
for(let i = 0; i < score.length; i++) {
if(i < k) {
array[i] = score[i]
answer.push(Math.min(...array))
} else {
array[i] = score[i]
array.sort((a,b) => b-a)
answer.push(array[k-1])
}
}
return answer
}