#K73007. Counting Occurrences in a List

    ID: 33879 Type: Default 1000ms 256MiB

Counting Occurrences in a List

Counting Occurrences in a List

You are given a list of integers and a target integer. Your task is to count the occurrences of the target in the list in a cumulative way. More specifically, for every index i such that L[i] == target, you need to output a key-value pair where the key is i and the value is the number of times the target has appeared in the list up to and including index i.

For example, if the list is [7, 7, 7, 7, 7] and the target is 7, then the output should be:

{0:1, 1:2, 2:3, 3:4, 4:5}\{0: 1,\ 1: 2,\ 2: 3,\ 3: 4,\ 4: 5\}

If the target is not present in the list, output an empty dictionary: {}. The indices in the output should be in increasing order.

inputFormat

The input is read from stdin in the following format:

  1. An integer n, the number of elements in the list.
  2. A line containing n space-separated integers representing the list.
  3. An integer representing the target value.

outputFormat

Output the dictionary (in Python-style format) that maps each index where the target is found to the cumulative count of occurrences up to that index. The output is printed to stdout.

## sample
5
1 2 3 4 5
3
{2: 1}