please help?

Revision en1, by zarif_2002, 2019-05-24 19:32:19

I have solved this problem with binary search before. https://codeforces.net/contest/1156/problem/C But, I am trying to find out a deque solution but it fails at test 7.Why? 54565879 the algo is here. 1. sort the vector, 2. push every element at the end of the dq, 3. while pushing we would check if the difference between back and front element is greater than z(q.back() — q.front() >= z). if this condition is true, then increment the ans and pop the front and back elements. 4. when we finished traversing through the array, we get the answer.

what's wrong? please.

Tags #deque, two pointers

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English zarif_2002 2019-05-24 19:32:19 611 Initial revision (published)