#BF0000038. Tuyển nhân viên thu ngân (Cashier Employment)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tuyển nhân viên thu ngân (Cashier Employment)
Cashier Employment
Source: POJ
Version: Phuoc Hung OJ Extended
Problem Statement
A store is open for 24 hours. Hour needs at least cashiers. Each of applicants has a fixed start hour and works 8 consecutive hours, possibly across midnight. Hire the minimum number meeting all hourly requirements, or print No Solution if impossible.
Shift coverage wraps around the 24-hour boundary.
This Extended version removes the leading count of independent test cases.
Input
Read 24 integers , then and start-hour integers .
Output
Print the minimum number to hire, or No Solution if impossible.
Subtasks
- Subtask 1 (20 points): $0\le N\le12; 0\le R_h\le1000 (0\le h<24); 0\le t_i\le23$.
- Subtask 2 (30 points): $0\le N\le150; 0\le R_h\le1000 (0\le h<24); 0\le t_i\le23$.
- Subtask 3 (50 points): $0\le N\le1000; 0\le R_h\le1000 (0\le h<24); 0\le t_i\le23$.
Examples
Input
1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
5
0 23 22 1 10
Output
1
Explanation
The sample requirements at hours , , , and can be covered by one suitably timed 8-hour shift when the shift wraps around midnight. The reference code evaluates all hourly requirements for the minimum.