Vending Machine Filling
Statement
Goal
A vending machine is divided into C compartments, each divided into S slots.A compartment cannot contain two different item types, and can contain at most S items, 1 per slot.
Identical item types can be spread across several compartments.
Given a list of items and their amounts, check if the vending machine can be properly filled.
Input
C amount of compartments in the machine.
S amount of slots in a compartment.
N amount of item types.
Next N inputs, separated by white space:
Amount of each item type.
S amount of slots in a compartment.
N amount of item types.
Next N inputs, separated by white space:
Amount of each item type.
Output
Constraints
1 ≤ C, S, N ≤ 1000
Example
Input
5 10 3 1 12 3
Output
yes 4
Game modes
Fastest, Shortest
Test cases
One overflow pass Test
Input
5
10
3
1 12 3
Output
yes 4
Validator 1 Validator
Input
6
10
3
1 23 1
Output
yes 5
One overflow fail Test
Input
2
10
2
11 9
Output
no 3
Validator 2 Validator
Input
5
10
2
41 1
Output
no 6
Single item overflow Test
Input
3
10
2
11 9
Output
yes 3
Validator 3 Validator
Input
4
10
2
21 9
Output
yes 4
2 Overflow Pass Test
Input
6
10
3
10 25 12
Output
yes 6
Validator 4 Validator
Input
7
10
3
10 26 21
Output
yes 7
2 Overflow Fail Test
Input
5
10
3
10 25 12
Output
no 6
Validator 5 Validator
Input
5
10
3
10 26 21
Output
no 7
1 Fill All Test
Input
1
999
1
999
Output
yes 1
Validator 6 Validator
Input
1
777
1
777
Output
yes 1
M multiple of S Test
Input
10
10
4
20 40 30 10
Output
yes 10
Validator 7 Validator
Input
11
10
4
20 50 30 10
Output
yes 11
All singles 1 small overflow Test
Input
10
10
10
1 1 1 1 1 1 1 11 1 1
Output
no 11
Validator 8 Validator
Input
11
11
11
1 1 1 1 1 1 1 12 1 1 1
Output
no 12
All singles no overflow Test
Input
10
10
10
1 1 1 1 1 1 10 1 1 1
Output
yes 10
Validator 9 Validator
Input
11
11
11
1 1 1 1 1 1 1 11 1 1 1
Output
yes 11
Solution language
Solution
Stub generator input