Whats wrong in this code

public static void main(String[] args) {

	Scanner sc=new Scanner(System.in);
	int N=sc.nextInt();
	int W=sc.nextInt();
	
	int val[] = new int[N+1];
	
	for(int i=1 ; i<=N ; i++)
		val[i]=sc.nextInt();
	
	int wt[] = new int[N+1];
	for(int i=1 ; i<=N ; i++)
		wt[i]=i;
	
	System.out.println(minmoney(N , W , wt , val));
	
}

static int minmoney(int n , int w , int[] wt , int []val)
{
	int []dp=new int[w+1];
	dp[0]=0;
	for(int i=1 ; i<dp.length ; i++)
		dp[i]=Integer.MAX_VALUE;
	
	
	for(int i=1 ; i<=w ; i++)
	{

		for(int j=1 ; j<val.length ; j++)
		{
			if(val[j]==-1) continue;
			
			if(i-wt[j]>=0)
				dp[i] = Math.min(dp[i] , dp[i-wt[j]] + val[j]);
		}
	
	}
	
	if(dp[w]==Integer.MAX_VALUE) 
		return -1;
	
	return dp[w];
}

Hey @Himanshu-Jhawar-2273952536067590
You doing wrong
Please read the question carefully:
Try for this input :
5 6
175 155 181 179 41 204
correct output : 204

explain the question , i am not getting it

Cody went to the market to buy some oranges for his N friends , There he finds orange wrapped in packets, with the price of i^th packet as val[i]. Now he wants to buy exactly W kg oranges, so he wants you to tell him what minimum price he should pay to buy exactly W kg oranges. Weight of i^th packet is i kg. If price of i^th packet is -1 then this packet is not available for sale. The market has infinite supply of orange packets.
Input N has no role in this question
This problem is can be reduced to 0-1 Knapsack Problem. So in cost array, we first ignore those packets which are not available i.e; cost is -1 and then traverse the cost array and create two array val[] for storing cost of ā€˜i’ kg packet of orange and wt[] for storing weight of corresponding packet. Suppose cost[i] = 50 so weight of packet will be i and cost will be 50.