user117860 I think about this too. It's interesting, that there is almost the same task on acmp, but there k<=500 and time limit 1 second