#P6367. [COCI 2006/2007 #6] PRASE
[COCI 2006/2007 #6] PRASE
Description
Children are having lunch at the table. There are portions of food, and the children take these portions one by one in order from to .
When a child takes a portion, if the number of portions he has already taken before this moment (excluding the current portion) is greater than the total number of portions taken by all other children, then his mom will remind him to mind his manners. Note that even if he is reminded, he will still take this portion. In other words, the reminder does not affect the child's behavior.
Given which child takes each of the portions, determine the total number of reminders given by the moms.
Input Format
The first line contains an integer , the number of portions.
Lines to : each line contains a string. The string on the -th line, , is the name of the child who takes the -th portion.
Output Format
Output a single integer: the answer.
4
mirko
stanko
stanko
stanko
1
17
a
b
b
a
a
a
c
a
b
b
c
b
b
b
b
b
b
4
Hint
Sample 1 Explanation
When the rd portion is taken, stanko has previously taken portion (excluding the current one), and the others have also taken portion in total, so stanko’s mom does not remind him.
When the th portion is taken, stanko has already taken portions, while the others have taken portion in total, so his mom reminds him.
Constraints
For all test cases, it is guaranteed that:
- .
- , and contains only lowercase English letters. denotes the length of the string.
Note
Problem translated from COCI2006-2007 CONTEST #6 T1 PRASE.
Translated by ChatGPT 5
京公网安备 11011102002149号