Need help in solving 158B — Taxi

Revision en1, by rick99y, 2019-02-09 21:12:16

Can someone help me with 158B - Такси ? I followed the editiorial .
I took the number of 4's and added them to the number of taxis, then I combined the 3's with 1's.
Now, either (i) 3's are in excess or (ii) 1's are in excess or (iii) none of the 1's or 3's are left.
I combined the 2's with themselves.
Now, either (a) an extra 2 is left or (b) isn't.
Taking these 6 cases:
(i)(a) I added the number of 3's left to the answer and the 2 goes in a seperate taxi.
(ii)(a) I added at max two 1's with the 2, and then combined the remaining 1's in groups of fours.
(iii)(a) only that last 2 is left, which goes separately.
(i)(b) I added the number of 3's left to the answer.
(ii)(b) I combined the remaining 1's in groups of four.
(iii)(b) nothing is left, everyone has been grouped.
It seems to work, but I'm getting a wrong answer on test case 66. (49551813) The test case is too big and isn't shown fully. I can't find where it's wrong. Can someone help?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rick99y 2019-02-09 21:12:16 1130 Initial revision (published)