I am worried as this has happened with me 3-4 times in 2 days.MY CODE IS RIGHT but fails for big input ie. 500000.When I see others solution i cannot understand their optimised approach??What should i do …
ssjgz
December 6, 2019, 6:59am
2
Actual submission link:
https://www.codechef.com/viewsolution/28060736
Here’s the Editorial solution:
PROBLEM SETTER -
ZCO 2014
DIFFICULTY -
Easy
PREREQUISITES -
Sorting
KEY OBSERVATIONS -
Sorting the array will not affect the answer as the answer doesn’t depend on the index of an element.
The answer would always be some element of the array, which is trivial to prove.
The revenue earned if we fix the price to be a[i], (for some 1 <= i <= N) will be a[i] * (N-i+1). Remember, the array is sorted in ascending order, and thus, there are(N-i-1) customers which have budget greater than a[i].
…
2 Likes