Did not understand the question (input/output)

did not understand how inputs are taking and outputs are coming

@deepgarg46 My code will help you for the problem :

public class HelpRamu {

    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int tc = scn.nextInt();

        while (tc > 0) {
            int c1 = scn.nextInt();
            int c2 = scn.nextInt();
            int c3 = scn.nextInt();
            int c4 = scn.nextInt();

            int nor = scn.nextInt();
            int noc = scn.nextInt();

            int[] freqr = new int[nor];
            int[] freqc = new int[noc];

            for (int i = 0; i < freqr.length; i++) {
                freqr[i] = scn.nextInt();
            }

            for (int i = 0; i < freqc.length; i++) {
                freqc[i] = scn.nextInt();
            }

            System.out.println(minAmount(c1, c2, c3, c4, freqr, freqc));
            tc--;
        }

    }

    private static int minAmount(int c1, int c2, int c3, int c4, int[] freqr, int[] freqc) {

        int rickshawMinFare = minVehicle(c1, c2, c3, freqr);
        int carsMinFare = minVehicle(c1, c2, c3, freqc);

        return Math.min(rickshawMinFare + carsMinFare, c4);

    }

    public static int minVehicle(int c1, int c2, int c3, int[] freq) {

        int sum = 0;

        for (int i = 0; i < freq.length; i++) {
            sum += Math.min(freq[i] * c1, c2);
        }

        return Math.min(sum, c3);

    }

}

sir i need some explanation for understand

@deepgarg46 We have taken input tc which will tell us how many test cases are there. For each test case we have to print the answer i.e. you have to calculate min amount for each test case. That’s why we have taken a while loop. In the while loop we will take the input required for the answer i.e. c1,c2,c3,c4,nor, noc, frequency array and cumulative freq array. and for each testcase print the output in new line.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.