PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: notsoloud
Tester: abhidot
Editorialist: iceknight1093
DIFFICULTY:
604
PREREQUISITES:
None
PROBLEM:
Given the ages of N people and the minimum age to vote X, find the number of people who can vote.
EXPLANATION:
This is a straightforward application of loops and conditional statements.
Iterate through the given array, and each time you have A_i \geq X, add one to the answer.
TIME COMPLEXITY
\mathcal{O}(N) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
n, x = map(int, input().split())
a = list(map(int, input().split()))
print(sum(1 for y in a if y >= x))