Jishan's Log 5: Codeforces 231A solution

 Codeforces 231A: Team


What the problem wants?

The 3 friends have formed a team and while solving problems, they want to make sure how many are confident about the solution. If 2/3 are confident, then they will implement the solution. Else they will ignore it.

How to solve the problem?

Algorithm:

For variable names, look at the code below:

1) take n tests as input
2) from i = 1 => 3 ( 0 => 2)
take an input, and see if it is 1. If it is, then increment the i_counter. Keep checking this for the remaining two. Lastly, check if the i_counter has values >= 2. If yes, increment the sol_counter and finally print it.

The Code:

#include<bits/stdc++.h>
using namespace std;

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
    int nscanf("%d"&n);
    int  sol_count = 0;
    while (n--)
    {
        int i_count = 0;
        for(int i=0i<3i++)
        {
            int xscanf("%d"&x);
            if(x == 1) {i_count++;}
        }
        if(i_count >= 2) {sol_count++;}
    }
    printf("%d\n"sol_count);
}
 

Comments

Popular posts from this blog

Jishan's Log 14: Codeforces 69A solution

Jishan's Log 12: Codeforces 236A solution

Jishan's Log 13: Codeforces 96A solution