[Practice ] Count Certificates | CodeChef
Setter: virtual_worm
Tester: rounak_rocco
Editorialist: codechef_ciem
DIFFICULTY:
EASY
PREREQUISITES:
None
PROBLEM:
There were N students (numbered 1 through N) participating in the Indian Programming Camp (IPC) and they watched a total of K lectures (numbered 1 through K). For each student i and each lecture j, the i-th student watched the j-th lecture for Ti,j minutes.
Additionally, for each student ii, we know that this student asked the question, “What is the criteria for getting a certificate?” Qi times.
The criteria for getting a certificate is that a student must have watched at least M minutes of lectures in total and they must have asked the question no more than 10 times.
Find out how many participants are eligible for a certificate.
QUICK EXPLANATION:
- We just take total of time spent over all lectures for each student and check both conditions.
SOLUTION(C++)
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
int a[n][k], i, j;
int q[n];
int ans = 0;
for (i = 0; i < n; i++) {
int sum = 0;
for (j = 0; j < k; j++) {
cin >> a[i][j];
sum += a[i][j];
}
cin >> q[i];
if (q[i] <= 10 && sum >= m)
ans++;
}
cout << ans << “\n”;