Editorial for COCI '17 Contest 1 #1 Cezar
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
We can maintain the array , where the member denotes the number of cards left in the deck of value . Initially, we set deck[2], deck[3], deck[4], deck[5], deck[6], deck[7], deck[8], deck[9] and deck[11] to 4, and deck[10] to 16. Now, every time we read a new card value, we decrease deck[value_of_read_card] by 1. Additionally, as we read the card values, we calculate their sum. In the end, let . The number of cards with the value greater than is then equal to the sum , whereas the number of cards with the value less than or equal to is equal to .
Comments
Where it reads "whereas the number of cards with the value less than X is equal to 52 − n" at the end of the editorial, shouldn't it read "whereas the number of cards with the value less than or equal to X is equal to 52 − n"?
Also, aren't the statistics calculated on "the number of the remaining cards in the deck", so the last figure one calculates is 52 - n - number of cards drawn?
"The number of cards in the deck with a value greater than 6 is 32 [...], whereas the number of cards in the deck with a value less than or equal to 6 is 14 [...]" ie 32 + 14 = 46, not 52.
Your first statement is correct and has been fixed.
Your second statement does not make sense: is defined as the number of cards drawn, so why would you subtract it twice?
Your third statement matches the logic described: you drew cards, so there are cards left, not .
Thank you, maxcruickshanks, for pointing out the errors in my logic and interpretation. Back to my random DOSTA/VUCI generator.