Hi,
Problem : 1676E — Eating Queries
My Approach : I sorted the array in descending order and then calculated the prefix sum, and then I am using binary search to find the least element greater than x.
Can anyone please tell me why my code is giving TLE.
Thanks.
Pass your prefix vector by reference
Thanks.
use pass by reference of your prefix vector 162614431
Thanks.
You can use pass by reference, have vector defined globally or implement binary search in your main function. Implementing it straight in main function is much faster because calling a faction with pass by value is not very fast and you are doing it
tq
times (at most150000000
) instead of, possibly, zero times.Thanks.
Try to debug yourself man
Thanks.