Home / Expert Answers / Computer Science / king-dreams-i-once-upon-a-time-a-king-saw-a-drearm-where-if-his-kingdom-has-gond-1-ine-of-tanks-pa624

# (Solved): KING-DREAMS-I once upon a time, a king saw a drearm, where if his kingdom has gond 1 ine of tanks . ...

KING-DREAMS-I once upon a time, a king saw a drearm, where if his kingdom has gond 1 ine of tanks . meaning tant lined up side thy side in a certair waly, they will become invinciblel. Now, since you are the advior of the king, he has asked you to create a good line of tanks. There are in types of tanks, numbered 1 through

`e`

, and we have infinite amount of tanks for each type. Come up with a good line of size in tanks. If there are multiple good line return one which is lexographically smallest. Come up with a good line of size

`n`

tanks. If there are multiple good 1 ine return one which is lexographically smallest. good line is a configuration where tanks lined up in an array and the count of subarrays with only distinct tank types is maximum. e.g

`{3,4,4,5}`

contains 6 subarrays with distinct tanks:

`{3},{4},h{4},{5},{3,4},{4,5}`

An array? is lexicographically smaller than an array? if there exists an index ? such that ??

`<`

??, and ??=?? for all

`1<=`

?1<=n<=1000001<=m<=10000000 Input Format The only line contain space seperated integer values

`n`

and

`m`

. where

`n`

is the size of good line

`m`

is the number of tank types Output Format Return a list of size

`n`

. Sample Input Example 1 Input: 12 Output: 1 Explanation: Max subarrays count with distinct tanks for line size 1 is 1. Possible line -

`{1},{2}`

We choose

`{1}`

as it is lexographically smallest. Example 2 Input: 21 Output: 11 Explanation: The only possible line

`-{1,1}`

Example 3 Input: 22 Output: 12 Explanation: Possible lines:

`{1,1},{1,2},{2,1}`

,

`{2,2}`

Lines

`{1,2}`

and

`{1}`

has max count of subarrays with distinct tanks.

We have an Answer from Expert