#P7755. Scoring Order Pairs

    ID: 20942 Type: Default 1000ms 256MiB

Scoring Order Pairs

Scoring Order Pairs

Given the correct order of n items and Mirko-wan's order, compute the score by counting every pair of items that are in the correct relative order. For every two items, if their order matches the order in the correct sequence, the student receives 1 point. The maximum possible score is given by the formula: \(\frac{n(n-1)}{2}\).

inputFormat

The first line contains an integer n representing the number of items. The second line contains n space-separated strings representing the correct order. The third line contains n space-separated strings representing Mirko-wan's order.

outputFormat

Output a single integer which is the score computed as the number of item pairs that are in the correct relative order.

sample

3
a b c
a b c
3