Cutting the array

3.8

12 votes
Mathematics, Easy, approximate, Basic Math, Mathematics
Problem

This is an Approximate Problem

You are given an array A. Now you need to partition this array into K+1 several sub arrays where K is the count of positions where you can perform a cut in the array. Note that the partitions should be continuous i.e. if you arrange all the partitions one after another they should form the initial array completely.

For example let the initial array A be [1,4,5,7,8,9] then example of few partitions are -
K=1 [1,4,5][7,8,9] - contains two partitions
K=2 [1,4][5,7,8][9] - contains three partitions
K=3 [1,4,5][7][8][9] - contains four partitions

Now your goal is to partition the array A in such a way that if we sum the count of divisors of the each individual partition sum then it should be as minimum as possible. Since this is an approximate problem every partition that follows the continuous condition is valid , only the scores will be different. It is recommended to go through the scoring section and the output section carefully.

Input
First line contains an integer N as input. Next line contains N space separated integers. Next line contains the value K denoting the count of cuts you need to make.

Output
Your output should contain K distinct space separated integers (ascending order) that denotes the positions of your cuts. Note that each position should belong to the range 1 to N1 both included.
For example : Suppose that the array is [1,5,7,9] and you perform a partition [1][5,7][9] then it means that there are 2 cuts one before the index 1 and one before the last index N1 as the array is indexed from 0 to N1. So one of the valid outputs will be - 
2
1 3

Constraints
1N104
1Kfloor(N/2)
1A[i]1000

Scoring and Verdicts
If your output format does not matches the one described above then you may get a runtime error or a wrong answer. If the partition is correct then you will get AC with a certain score for which it may be possible to increase/decrease the score with certain optimizations.
Suppose that the sum of the count of divisors of each partition is X then your score is X2 and your goal is to minimize this score as much possible. Lesser the score more better is the solution.

Sample Input
3
1 2 3
1
Sample Output
1
Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

In the sample output the partition is performed before the index 1 which means that the array is partitioned into [1] and [2,3]. The partition sums are 1 and 5. First partition has divisor count 1 and second has divisor count 2. So here X=3. The score will be X2 which is 9.

Editor Image

?