Namuhs

두 부분 배열의 합을 비교하는 질의만 사용해 합이 최대인 유일한 연속 구간을 찾아야 한다.

어려움9분할 정복이분 탐색누적 합완전 탐색아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

The humanoid aliens from the planet Htrae (they are called namuhs) are at the peak of their development and they can create living creatures. After a big journey around our known universe a special team has made a list of planets sorted by their distance from the Htrae. The team has given the list to “The high council” of the namuhs who analyzed this information in details and decided to assign of every planet an integer number to describe its potential for the experiment. The chief of “The high council” is Deni and she has to decide which planets will take part in the plan. Because the distances in space are very big even for this advanced race, it has to be chosen only one set of planets, which are adjacent in the list – i.e. they should form a segment. The total potential of one set of planets is equal to the sum of the potentials of every planet in it. “The high council” has decided that the chosen set has to be one with the highest possible total potential. Deni remembered that she knows one planet not far away – the planet Earth, where the civilization (of the so called humans) isn’t so advanced but there are creatures which can help her to make a program for this problem. Namuhs don’t want to give away this secret information so the only access to that data you have, is through asking questions about comparing the sums of two segments of planets.

You have to implement a function find_max which will be compiled with the source file of the jury (of Deni) and has to return two numbers for the segment of adjacent planets which have the highest possible total potential. This function will receive one number N – the number of planets. The jury has the values of planets potentials in appropriate order. Your goal is through asking questions for comparing segments of adjacent planets to find the segment with the highest possible potential. It is guaranteed that there is only one answer!

제한

  • 2 ≤ N ≤ 105