๐Ÿ“˜ Day 10 โ€“ Teacher's Day Challenge | Next Round Qualification

TanishiTanishi
2 min read

๐Ÿ—“๏ธ Date: August 03, 2025
๐Ÿงฉ Platform: Codeforces
๐Ÿ”ข Problems Solved Today: 1
๐ŸŽฏ Focus Topic: Arrays, Conditional Logic, Ranking System


๐Ÿ”— Table of Contents


๐Ÿงฉ Problem 1 โ€“ Next Round

๐Ÿ“š Difficulty: Easy
๐Ÿง  Concepts: Array Traversal, Indexing, Score Threshold


๐Ÿ“„ Problem Statement (Summary):
You are given the scores of n participants in non-increasing order and an integer k.
A participant advances to the next round if:

  • Their score is โ‰ฅ score of the k-th participant, and

  • Their score is greater than 0.
    Count how many participants will advance.

๐Ÿ“ Example:
Input:

8 5  
10 9 8 7 7 7 5 5

Output:

6

๐Ÿ’ก Approach:

  • Input n and k, and store n scores in a vector.

  • The score of the k-th participant is nums[k-1].

  • Traverse all scores:

    • If current score โ‰ฅ nums[k-1] and > 0, count it.
  • Print the final count.


๐Ÿงช Code (C++):

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, k, c = 0;
    cin >> n >> k;
    vector<int> nums(n);
    for (int i = 0; i < nums.size(); i++)
        cin >> nums[i];
    for (int i = 0; i < n; i++) {
        if (nums[i] >= nums[k - 1] && nums[i] > 0)
            c++;
    }
    cout << c;
    return 0;
}

๐Ÿ“ธ Submission Screenshot:
(Attach your accepted screenshot here using โž• image in editor)


โœ… Key Takeaways:

  • Carefully access the k-th element using k-1 index (0-based indexing).

  • Ensure the score is positive before counting.

  • The non-increasing order guarantees we can compare directly from the front.

  • Clean array traversal with simple conditions is key.


๐Ÿ“ˆ Daily Summary

MetricValue
Problems Solved1
Topics CoveredArrays, Ranking Logic
Tools UsedC++
Next FocusPrefix Sum, Basic Sorting
Day10 / 30

๐Ÿท๏ธ Tags:
#codeforces #arrays #ranking #contestlogic #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