Due to the installation of a new fire alarm in ITMO server room, the system may be occasionally unavailable on the 27-th of May between 06:00 and 15:00 (UTC). ×

Master_coder's blog

By Master_coder, history, 4 weeks ago, In English,

Given N keys and values , and q queries for each query you have given key you have to find key smaller than given key with maximun value . for example:- keys — 2 3 1 6 4 values — 5 1 6 2 8 given key 5 must produce output 8 i.e (4,8)


4 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

Sort the keys. Make another array that Max. Max[I] will store the maximum value till index I. You can search the index where the key is just smaller than the input key with lower_bound. Let the index is Ind then the answer is nothing but Max[Ind].