372. Tea Party
Time limit per test: 0.25
Memory limit: 65536
Alice organizes a tea party for her classmates. There are K
guests on this party and N
types of tea of two kinds: black and green. During each party round, all guests who are currently present on the party get one bag of the same type of tea. After each party round, one of the guests leaves the party because he/she needs to meet somebody elsewhere. Alice needs to minimize the total cost of tea bags spent, but she also wants to make it so that all served tea types must be different, and any three consecutive rounds of the party are not using tea of the same kind. Help her.
The first line of the input contains two integers K
≤ 1000). N
lines follow, each for one tea type, containing two integers ci
), where ci
is the cost of one bag of i
-th type, and si
is zero for green tea and one for black tea.
Output any possible optimal party plan — K
different numbers between 1 and N
, each for one type of tea. If it is impossible to organize the party, output "
" without quotes.
1 2 4