πŸ“˜ Day 9 – Teacher's Day Challenge | Team

TanishiTanishi
2 min read

πŸ—“οΈ Date: August 02, 2025
🧩 Platform: Codeforces
πŸ”’ Problems Solved Today: 1
🎯 Focus Topic: Conditional Logic, Input Handling, Majority Voting


πŸ”— Table of Contents


🧩 Problem 1 – Team

πŸ“š Difficulty: Easy
🧠 Concepts: Majority Check, Conditional Logic, Input/Output


πŸ“„ Problem Statement (Summary):
Three friends β€” Petya, Vasya, and Tonya β€” will solve a problem only if at least two of them are sure about it.
You’re given n problems and each problem has 3 integers (0 or 1) indicating whether each friend is sure.
Count how many problems they will implement.


πŸ’‘ Approach:

  • Input number of problems n.

  • For each problem, take 3 values (0 or 1) for Petya, Vasya, Tonya.

  • Sum the three values. If the sum is β‰₯ 2, increment the answer count.

  • Finally, print the count.


πŸ§ͺ Code (C++):

#include <iostream>
using namespace std;
int main() {
    int n, ans = 0;
    cin >> n;
    while (n--) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a + b + c >= 2) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

πŸ“Έ Submission Screenshot:


πŸ“ Example:
Input:

3  
1 1 0  
1 1 1  
1 0 0

Output:

2

βœ… Key Takeaways:

  • Sum of binary values (0/1) is a quick way to perform majority check.

  • if (a + b + c >= 2) is clean and efficient.

  • Looping with while (n--) is commonly used in competitive programming.

  • Input format understanding is critical in Codeforces problems.


πŸ“ˆ Daily Summary

MetricValue
Problems Solved1
Topics CoveredLogic, Binary Input Handling
Tools UsedC++
Next FocusArrays, Basic Math
Day9 / 30

🏷️ Tags:
#codeforces #conditional #logic #majority #cpp #dsa #43DaysChallenge

0
Subscribe to my newsletter

Read articles from Tanishi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tanishi
Tanishi