Напоминание: в случае технических проблем любого характера, вы можете использовать m1.codeforces.com, m2.codeforces.com, m3.codeforces.com. ×

HELP in implementation of sort STL for vector pair C++
Разница между en1 и en2, 16 символ(ов) изменены
I had a vector of pairs. I wanted it sorted in descending according to the first value of the vector. ↵

~~~~~↵
sort(a.begin(),a.end(),[](pair<int,int> &left, pair<int,int> &right){↵
         return left.first >= right.first;↵
});↵
~~~~~↵

This gave me TLE. Sorting it normally ↵

~~~~~↵
sort(a.begin(),a.end());↵
~~~~~↵

and iterating from the end worked. ↵

Why does the first sorting function give TLE? Do I have to implement it some other way?↵

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский hell_hacker 2017-09-13 19:06:50 16
en1 Английский hell_hacker 2017-09-13 19:00:22 494 Initial revision (published)