#K66937. Completely Filled Cars
Completely Filled Cars
Completely Filled Cars
You are given a list of integers representing the number of seats in each car and an integer representing the total number of riders. A car is considered completely filled if the remaining number of riders is greater than or equal to the number of seats in that car. Once a car is completely filled, subtract the number of seats from the total riders. The process stops immediately when a car cannot be completely filled.
Formally, for each car with seating capacity (s_i), if the remaining riders (r) satisfy (r \ge s_i), then the car is filled and the riders are updated as (r = r - s_i); otherwise, the process stops. Your task is to compute the total number of completely filled cars.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
1. The first line contains an integer (n), representing the number of cars.
2. The second line contains (n) space-separated integers, where each integer represents the number of seats in a car in the order they are to be filled.
3. The third line contains a single integer representing the total number of riders available.
outputFormat
Output a single integer to standard output (stdout) indicating the number of cars that are completely filled.## sample
5
4 3 2 5 1
7
2