Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: beecrowd problem 1001 solution in c++ 
Cpp :: Opengl GLFW basic window 
Cpp :: how to measure cpp code performace 
Cpp :: viewlist exaple win32 
Cpp :: gcd multi num 
Cpp :: how to use string in if else statement c++ 
Cpp :: cpp get keystroke in console only 
Cpp :: find with hash set 
Cpp :: case 1 or 2 c++ 
Cpp :: c++ put a function in a other thread 
Cpp :: Fill 2-dimensional array with value 
Cpp :: facade pattern C++ code 
Cpp :: sleep function i nc++ 
Cpp :: C++ singleton prevent copy 
Cpp :: c++ trim string 
Cpp :: ubuntu dotnet create blazorserver linux 
Cpp :: converting a string to lowercase inbuld function in cpp 
Cpp :: shrek c++ 
Cpp :: create a table using pointers in C++ 
Cpp :: high school hacking competition 
Cpp :: multiple inheritance c++ 
Cpp :: fabs in c++ example 
Cpp :: c++ void pointer 
Cpp :: find a member variable in a vector of objects cpp 
Cpp :: how to traverse string like array in cpp 
Cpp :: c++ code 2d block 
Cpp :: displaying m images one window opencv c++ 
Cpp :: wap in c++ to understand function template 
Cpp :: is vowel c++/c 
Cpp :: pointeur cpp 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =