Company: Deutsche bank_7aug
Difficulty: medium
Minimum price Problem Description There are N stones lying in a line. The stone at position i ( 1 <= i <= N ) costs a[i] units and is initially of type i , so at the start the line holds exactly one stone of each type 1, 2, ..., N . You start with no stones, and you want your collection to contain all N types: type 1 , type 2 , ..., type N . You may do the following actions, any number of times and in any order: Buy the stone at any position i . You pay a[i] and a stone of the type that position currently has is added to your collection. The position keeps its stone, so it can be bought again later at the same price. Apply the operation , which costs X units. Every stone in the line changes its type in one step: a stone of type i becomes type i + 1 , and a stone of type N becomes type 1 . Stones already in your collection keep the type they had when you bought them. Print the minimum total price you have to pay to get all N types of stones into your collection. Function Descripti