Canadian Computing Olympiad: 2022 Day 1, Problem 2
There are
For each
Right now, the
Suddenly, it starts raining, and everyone at market
- to go to bus shelter
; - to go to bus shelter
; or - to stay and buy an umbrella.
If a person is unable to find a place in a bus shelter or buy an umbrella, they will get wet.
If everyone coordinates optimally, can they all stay dry? If so, what is the least amount of money they need to spend, and which bus shelter should each person move to?
Input Specification
The first line of input contains an integer
The second line of input contains
The third line of input contains
The fourth line of input contains
Marks Awarded | Number of bus shelters | Maximum people/bus shelters | Maximum people/market | Maximum umbrellas/market |
---|---|---|---|---|
Output Specification
If every person can stay dry either under an umbrella or at a bus shelter, the output will be
- the first line will contain the word
YES
. - the second line will contain the least amount of money necessary to spend on umbrellas
- the next
lines will each contain three space-separated integers:- the number of people at market
moving to bus shelter - the number of people at market
buying an umbrella - the number of people at market
moving to bus shelter , where .
- the number of people at market
If not every person can stay dry, the output will be one line containing the word NO
.
If there are multiple possible correct outputs, any correct output will be accepted.
Sample Input 1
3
10 15 10
20 20
0 0
Output for Sample Input 1
NO
Explanation of Output for Sample Input 1
There are
Sample Input 2
3
10 15 10
20 20
0 11
Possible Output for Sample Input 2
YES
5
10 0 10
5 5 10
Explanation of Output for Sample Input 2
Looking at market
Looking at market
In total,
Comments