Company: Acresium
Difficulty: medium
The Grand Orchestra Crescendo You are the conductor of a grand orchestra with m musicians seated in a row at positions 0 to m - 1 . Musician i can play at any integer intensity from 0 up to intensity[i] , inclusive - a musician who plays 0 simply stays silent. You are composing a single dramatic piece. Let played[i] be the intensity musician i actually plays. The piece must have exactly one crescendo : there must be a position p such that the intensities never decrease as they approach p : played[0] <= played[1] <= ... <= played[p] , and the intensities never increase as they move away from p : played[p] >= played[p+1] >= ... >= played[m-1] , and position p is strictly louder than each of its immediate neighbours - that is, played[p] > played[p-1] when p > 0 , and played[p] > played[p+1] when p < m - 1 . The third rule is exactly the requirement that at most one musician plays the highest intensity in the piece. The crescendo point p may be at any position