Team

Team
Codeforces easy

There are \(3\) friends and \(N\) problems. A problem can be solved if and only if \(2\) or more friends know its solution.

For each of the \(N\) problems, given whether or not each friend knows its solution, your task is to count how many problems can be solved.

Solution

We will simply loop over the problems and count the number of friends that know its solution. If the count is at least \(2\) we will increment an integer counter which will be our output.

#include<iostream>
using namespace std;

int main () {
    int n;
    cin >> n;

    int ans = 0;

    for (int i = 0 ; i < n ; i++) {
        int f1, f2, f3;
        cin >> f1 >> f2 >> f3;

        if (f1 + f2 + f3 >= 2) ans++;
    }

    cout << ans;
}