A Subtask Problem Problem Code: SUBTASKSubmit
Chef recently solved his first problem on CodeChef. The problem he solved has test cases. He gets a score for his submission according to the following rules:
1) If Chef’s code passes all the test cases, he gets points.
2) If Chef’s code does not pass all the test cases, but passes all the first test cases, he gets points.
3) If the conditions and are not satisfied, Chef does not get any points (i.e his score remains at points).
You are given a binary array of length , where denotes Chef's code passed the test case, denotes otherwise. You are also given the two integers . Can you find how many points does Chef get?
Input Format
- First line will contain , number of testcases. Then the testcases follow.
- The first line of each test case contains three space-separated integers .
- The second line contains space-separated integer .
Output Format
For each testcase, output in a single line the score of Chef.
Constraints
Sample Input 1
4
4 2 50
1 0 1 1
3 2 50
1 1 0
4 2 50
1 1 1 1
5 3 30
1 1 0 1 1
Sample Output 1
0
50
100
0
Explanation
Test case : Chef's code neither passes all test cases nor passes the first test cases. Hence he does not get any points.
Test case : Chef's code does not pass all test cases, but passes the first test cases. Hence he gets points.
Test case : Chef's code passes all the test cases. Hence he gets points.
solution
#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 << "\n";
}
return 0;
}
No comments:
Post a Comment