Help Rohit Solution

Solution  :-

#include<iostream>
using namespace std;
int min(int num1, int num2) {
	if (num1 >= num2)
		return num1;
	else
	{
		return num2;
	}
	
}

int main() {
	int t;
	cin >> t;
	int c1, c2, c3, c4,n,m;
	
	int rick[1005];
	int cabs[1005];
	while (t--) {
		cin >> c1 >> c2 >> c3 >> c4;
		cin >> n >> m;
		for (int i = 0;i < n;i++) {
			cin >> rick[i];
		}
		for (int i = 0;i < m;i++) {
			cin >> cabs[i];
		}
		int rickCost = 0;
		for (int i = 0;i < n;i++) {
			rickCost += min(rick[i] * c1, c2);
		}
		rickCost = min(rickCost, c3);
		int cabCost = 0;
		for (int i = 0;i < m;i++) {
			cabCost += min(cabs[i] * c1, c2);
		}
		cabCost = min(cabCost, c3);
		int finalCost = min(c4, cabCost + rickCost);
		cout << finalCost << endl;
	}

	return 0;
}

Contact us





JDoodle for WordPress
Scroll Up