Singularity Cup P1 - Maximum Permutation Product

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

You are given a permutation P of the integers 1 to N.

We define the value of any non-empty contiguous subarray in P as its product divided by its length.

More formally, the value of some range [l,r] is Pl×Pl+1××Prrl+1.

Find a subarray [l,r] that results in the maximum possible value.

Constraints

1N2×105

1PiN

P is a permutation of 1,2,,N.

Subtask 1 [20%]

N15

Subtask 2 [80%]

No additional constraints.

Input Specification

The first line of input contains an integer N.

The next line of input contains N space-separated integers representing P.

Output Specification

Output 2 space-separated integers l and r, representing any maximum value subarray [l,r].

Sample Input

Copy
4
3 1 4 2

Sample Output

Copy
1 4

Comments

There are no comments at the moment.