Valentine Magic

question Valentine Magichttps://hack.codingblocks.com/contests/c/537/825
In my solution I am getting TLE https://hack.codingblocks.com/submission/1456199
Please help me out.

Hey Ayush, we are not able to see your submission can you please copy your code on ide, save it and share that link here.

https://ide.codingblocks.com/s/46359
solution is here.

Hey Ayush, this problem is a very simple implementation of greedy. So, i would suggest you to try greedy approach for this problem. Hint is you can sort both the arrays.