C++20 sections · 1024 units
Open in Course

Next Round - Implementation

Complete solution

Read input, store the threshold, then count qualifying scores:

#include <iostream>
using namespace std;
int main() {
 int n, k;
 cin >> n >> k;
 int scores[n];
 for (int i = 0; i < n; i++) {
 cin >> scores[i];
 } int threshold = scores[k - 1];
 int count = 0;
 for (int i = 0; i < n; i++) {
 if (scores[i] > 0 && scores[i] >= threshold) { count++;
 } } cout << count << endl;
 return 0;
}
``` The condition scores[i] > 0 && scores[i] >= threshold captures both requirements. The compound condition checks both the score threshold AND positivity.