#P4439. Queue Position Determination
Queue Position Determination
Queue Position Determination
Aron visited a toy store in London during the holiday season and found that there were already N people in line. However, he noticed that people were standing in groups (a customer along with their friends waiting for them) as well as individual customers. Once the customer finishes paying, the entire group leaves the line at once. People belonging to a group are standing consecutively and wear shirts of the same colour. Note that two adjacent segments (whether groups or individuals) will never have the same shirt colour.
Your task is to determine Aron's position in the line, assuming that each group (or individual) is served in one transaction.
We can define the number of groups by the formula: $$numGroups = 1 + \sum_{i=1}^{N-1} [a_i \neq a_{i+1}]$$ where represents the shirt colour of the i-th person (provided they are given in order) and $$[P]$$ is 1 if the predicate P is true, else 0.
Aron will take place right after all these groups, so his position is $$numGroups+1$$.
inputFormat
Input Format:
The first line contains an integer N (N > 0), which denotes the number of people in line.
The second line contains N space-separated strings, each representing the colour of the shirt the person is wearing.
outputFormat
Output Format:
Output a single integer which is the position Aron will have in the line.
sample
5
red red blue blue green
4