Solusi Codechef Masalah Subtugas di 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 << "\n";
}
return 0;
}
coder