Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

A Subtask Problem codechef solution in cpp

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

int main()
{

   int t;
   cin >> t;
   for (int j = 0; j < t; j++)
   {
	   int n, m, k;
	   cin >> n >> m >> k;
	   vector<int> v(n);
	   //fill vector
	   for (int i = 0; i < n; i++)   cin >> v[i];
	   //check n
	   int cn = 0;
	   for (int i = 0; i < n; i++)
	   {
		   if (v[i] == 1)
			   cn++;
	   }
	   //check m
	   int cm = 0;
	   for (int i = 0; i < m; i++)
	   {
		   if (v[i] == 1)
			   cm++;
	   }
	   //put score
	   int score;
	   if (cn == v.size())
		   score = 100;
	   else if (cm == m)
		   score = k;
	   else
		   score = 0;
	   //print score
	   cout << score << "
";
   }

	return 0;
}
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #A #Subtask #Problem #codechef #solution #cpp
ADD COMMENT
Topic
Name
2+3 =