Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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 << "
";
	}
};
int main()
{
	solution ss;

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

	return 0;
}
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #Chef #Vaccination #Queue #codechef #solution
ADD COMMENT
Topic
Name
6+1 =