I am talking about this question. I read the tutorial and I my approach is very much similiar to that. But I am getting tle. Here is my approach
I used 2 sets, one for the skills(val) and one for the indexes(indexes). I also maintained the an ind array. ind[i] is the index of i in in the orignal array (1 based index).
Now while the indexes set is not empty do the the following: Find the largest element in the val set. Find its index in the orignal array fron the ind array.
Locate this index in the indexes set using find method. Then move backward and forward and delete k elements both from the indexes and val set. Assign the teams in alternate fashion. I didn't delete while traversing. First I traversed the set k elements left and right and stored all the indexes in a vector. Then I traversed the vector and delete from the indexes and val set.
This is the submission. Since every element is deleted and traversed only once its time complexity is NlogN. Plese help what is wrong with this submission
UPD : Finally solved the problem. The mistake I was comitting was using find() instead of set.find()