DSA week 1-Smart Phone problem

,

My answer has been partially accepted but I am not able to rectify the mistake and it is showing “RE (SIGSEGV)” in subpart 2(70 marks). Here’s the link to my solution- solution. Please help.

1 Like

In second test case, The constraints are 5×10^5 you have declared an array of 5000 only.
Then too if we are correcting it it is giving TLE in subtask 2.
Here is the link to the submission without RE:
https://www.codechef.com/viewsolution/36045795
Try removing the TLE yourself tho.

Hint

Try sorting the array and the number of elements at greater index will be larger than the number.

1 Like

Could someone plz help me
Link to my solution :- CodeChef: Practical coding for everyone
As you can see I have used sorting and then multiplying by index and max method in c++ but I am getting WA in 2-3 questions (partially correct). I looked at many discussions but none addressed this fact. What is wrong here?