Fighting Routine
Time limit2sMemory limit512 MB
For every window length d from 1 to n, sum the number of distinct task types over all length-d windows of the given array.
- Level
Medium7 of 10
- Topics
- Array, Prefix sum, Combinatorics, Math
- Solved
- No attempts yet
Problem
Fighting routine is an important part of improving employee productivity. Let us build a mathematical model of the diversity of task types an employee performs at a company.
Consider an employee working over consecutive working days. Every day the employee performs exactly one type of task; let the type of task performed on day be an integer .
To measure how routine the employee's work is, we use the following quantity. Fix an integer and consider all segments of consecutive working days. For each such segment, count the number of distinct task types the employee performed over those days, then sum these counts. Call the resulting value , the -diversity. The higher the -diversity, the more distinct task types the employee performed. The variability profile of the employee is the array .
Write a program that, given the sequence of task types the employee performs, computes the variability profile of that employee.
Input
The first line contains a single integer , the number of consecutive working days to analyze ().
The second line contains integers , the task types the employee performed ().
Output
Print integers: .
Hint
Consider how the values are computed in the first sample.
1-diversity: sum the number of distinct task types the employee performed over all segments consisting of one day.
The 1-diversity value is .
2-diversity: sum the number of distinct task types the employee performed over all segments consisting of two days.
The 2-diversity value is .
3-diversity: sum the number of distinct task types the employee performed over all segments consisting of three days.
The 3-diversity value is .
4-diversity: sum the number of distinct task types the employee performed over all segments consisting of four days.
The 4-diversity value is .
5-diversity: sum the number of distinct task types the employee performed over all segments consisting of five days.
The 5-diversity value is .