Huawei OD Online OJ:
Users who have already purchased this column, please private message the blogger to open an account and brush up questions online! ! !
Online OJ: brush the questions immediately
Question bank column: 2023 Huawei OD machine test (A volume + B volume) (C++JavaJSPy)
topic description
The parking lot of a specific size is represented by the array cars[], where 1 means there is a car and 0 means there is no car.
Vehicles are of different sizes, cars occupy one parking space (length 1), trucks occupy two parking spaces (length 2), and trucks occupy three parking spaces (length 3).
Count the minimum number of cars that can be parked in the parking lot, and return the specific number.
enter description
The integer string array cars[], where 1 means there is a car, and 0 means there is no car, and the length of the array is less than 1000.
output description
Integer numeric string, indicating the minimum parking number.
Example
enter | 1,0,1 |
output | 2 |
illustrate | 1 car occupies the first parking space The second parking space is empty 1 small car occupies the 3rd parking space at least two cars |
enter | 1,1,0,0,1,1,1 |