Count Elements Greater Than K
EasyPractice library · +10 XPhash mapcountingconditionals
Given a list of N integers and an integer K, count how many elements in the list are strictly greater than K. Print this count.
Input
The first line contains two integers, N and K. The second line contains N space-separated integers.
Output
Print a single integer: the count of elements greater than K.
Constraints
1 <= N <= 1000 -1000 <= K <= 1000 -1000 <= A[i] <= 1000, where A[i] is the i-th integer in the list.
Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests
Example 1
Input
5 3 1 5 2 8 3
Output
2
Elements 5 and 8 are greater than 3. Count is 2.
Example 2
Input
4 10 1 2 3 4
Output
0
No elements are greater than 10. Count is 0.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 3 1 5 2 8 3
Example 2 input
4 10 1 2 3 4