What I am doing wrong?

I am trying to solve a Dynamic Programming problem. I made the recursive function which is working correctly but when I am using memoization then I am getting wrong answer. Please tell me what I am doing wrong? Thank You.
Here is the problem : Maximum Tip Calculator | Practice | GeeksforGeeks
Here is my solution: 4M8UKE - Online C++ Compiler & Debugging Tool - Ideone.com

I think you mean to zero-initialize the aTip array instead of zeroing the array rTip twice in your init() function.

you don’t need a DP approach for this problem.
see this O(n) approach.

I am getting wrong answer for the first test case also. After correcting the init() function. Still getting wrong answer.

I want to learn DP that’s why I am solving currently dp problems only and try to solve them with dp approach.

A small correction, you are sorting so it would be O(n log n)