#C10243. Counting Trees with Reduced Height
Counting Trees with Reduced Height
Counting Trees with Reduced Height
You are given an integer n representing the number of trees planted, followed by two lists each containing n integers. The first list represents the initial heights of the trees and the second list represents the heights after a storm hit. Your task is to determine how many trees experienced a reduction in height, i.e. the trees for which the initial height is greater than the height after the storm.
The problem can be mathematically represented as follows:
Let \( A = [a_1, a_2, \dots, a_n] \) be the initial heights and \( B = [b_1, b_2, \dots, b_n] \) be the heights after the storm. You need to compute the number of indices \( i \) such that \( a_i > b_i \).
inputFormat
Input is read from stdin and has the following format:
- The first line contains a single integer n (1 ≤ n ≤ 105), the number of trees.
- The second line contains n space-separated integers, representing the initial heights of the trees.
- The third line contains n space-separated integers, representing the heights of the trees after the storm.
outputFormat
Output a single integer to stdout: the number of trees that have lost height after the storm.
## sample5
3 4 1 7 8
2 4 1 5 7
3