https://www.codechef.com/START7C/problems/MAXSWT

I wanted help with this question. I tried every test case but it is giving wrong answer. please help.

my code:

```
import operator
def solve(no_of_candies,dollars,prices,sweetness):
if len(set(prices)) == 1:
sweet=0
for i in range(0,len(prices)):
if prices[i]<=dollars:
sweet=sweet+max(sweetness)
sweetness.remove(max(sweetness))
dollars=dollars-prices[i]
return sweet
dictionary= dict(zip(prices, sweetness))
sorted_d = dict( sorted(dictionary.items(), key=operator.itemgetter(1),reverse=True))
max_candies=2
sweet=0
for i in sorted_d:
if i<=dollars:
if max_candies!=0:
sweet+=sorted_d[i]
max_candies-=1
dollars=dollars-i
return sweet
t=int(input())
for i in range(t):
no_of_candies,dollars=map(int,input().split())
prices=list(map(int,input().split()))
sweetness=list(map(int,input().split()))
print(solve(no_of_candies,dollars,prices,sweetness))
```