No passing any test cases

   import java.util.*;
   public class Main {
  public static int minPriceBU(int price[], int wt){
	int n=price.length;
	int weight[]=new int[n];
	for(int i=0;i<n;i++){
		weight[i]=i+1;
	}


	int dp[][]=new int[n+1][wt+1];
	for(int row=0;row<=n;row++){
		for(int col=0;col<=wt;col++){
			if(row==0){
				dp[row][col]=Integer.MAX_VALUE;
				continue;

			}
			if(col==0){
				dp[row][col]=0;
				continue;
			}
			if(weight[row-1]>col){
				dp[row][col]=dp[row-1][col];

			}
			else if(col>=weight[row-1]&&price[row-1]!=-1){
				dp[row][col]=Math.min(dp[row-1] 
      [col],dp[row][col-weight[row-1]]+price[row-1]);
			}
		}
	}
	return dp[n][wt];

   }

   public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int wt=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++){
	arr[i]=sc.nextInt();
}
int ans=minPriceBU(arr,wt);
if(ans==Integer.MAX_VALUE){
	System.out.println(-1);

}
else{
	System.out.println(ans);
}

 }


}

try to debug for the test case
5 6
175 155 181 179 41 204
the correct answer is 204 you are getting 216

i am getting 204 , you are taking 5 as number of friend but you try to enter 6 numbers , that’s why you are getting wrong ans for this test case.

this is input fomat:
Input Format

First line of input contains two space separated integers N and W, the number of friend he has and the amount of Oranges in kilograms which he should buy.

please solve my probelm.

If you read the problem statement carefully then you will realise that the N value given in input does not represent the size of the array. Infact it is quite useless.
This is a 1D DP problem. The size of the array is W only , not N.

please check my solution , and tell where is mistakes in my code. please

you mean i need to take number of input equal to W???

yes …
that’s right