First of all, you should count the number of people the company is hiring. The code is calculating the opposite.
Secondly, the code is comparing kth element of v1 with the wrong value, which are v1[0].second, v2[0].second.
sort(v1.begin(), v1.end()) will sort the pair in the order of smallest v1[i].first as first element therefore v1[0].second can be larger than smallest element of v1[i].second.
This is the sample case of such situation;

shehddhks 2년 전
why my code is wrong?