Request for Help with CP Problem

Revision en1, by BinaryCrazy, 2020-04-02 01:49:16

Hi all,

Hope you are having a great day. I found this question on HackerEarth, and received a "Partially Accepted" verdict, but have no idea why.

Can someone please explain where my logic is wrong? I have listed my logic below.


Logic

Sort all the values for which one needs to perform the HIT operations.

Next, for each value, binary search to find the last index that satisfies the following inequality:

a[i] — i >= x[i] (1 indexing)

We subtract that from the original value, and output the resulting array.

Implementation.


Thanks a lot for your time and help.

It is greatly appreciated.

Regards,

BC

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English BinaryCrazy 2020-04-02 01:49:16 941 Initial revision (published)