Answers for "Chef in Vaccination Queue codechef solution in c++"

C
0

Chef in Vaccination Queue codechef solution in c++

#include<iostream>
#include<algorithm>
using namespace std;

class solution
{
public:
	void solve()
	{
		int n, p, x, y;
		cin >> n >> p >> x >> y;
		int* arr = new int[n];
		for (int i = 0; i < n; i++)
		{
			cin >> arr[i];
		}
		int total = 0;
		for (int i = 0; i < p; i++)
		{
			if (arr[i] == 1)
				total += y;
			else
				total += x;
		}
		cout << total << "\n";
	}
};
int main()
{
	solution ss;

	int t;
	cin >> t;
	while (t--)
    {
		ss.solve();
	}

	return 0;
}
Posted by: Guest on March-15-2022

Code answers related to "Chef in Vaccination Queue codechef solution in c++"

Code answers related to "C"

Browse Popular Code Answers by Language