HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Dynamic programming & Greedy > problem:


50545 - Diet

Guest
• Discussion of problem (1)

Section problems

• 50561 - Lucky tickets
• 50598 - Minimum Sum
• 50601 - Increasing sequence
• 50613 - Zapakovka
• 50680 - Triangle
• 50683 - Parking Buses
• 50685 - Guest Room Usage
• 50544 - Stock market
• 50545 - Diet

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/7000/7000/7000 ms. Memory limit 65000/65000/65000/65000 Kb.
Olympiad 2012. Prepared by: Evis Hoxha. Difficulty Alpha

Question 2. Diet

Given n values that represent the ups and downs of the weight during some diet days. Positive values represent increase in weight, while negative values represent decrease in weight. Write a program that after reading the values of each day, determines if there exists a day such as the sum of the changes in weight in the previous days is equal to the sum of the changes in weight in the following days.
The sum of changes is calculated by adding the values for each day.

Input

The first line contains the number of days n, where 3<=n<=10000. The second line contains the values for each day.

Output

If a day fulfilling the requirements exists, show the number of the day. If such a day does not exist, show 0.



Input I

10
100 200 -500 200 300 150 350 -600 150 -50

Output 1

5


Explanation:
100+200-500+200=150+350-600+150-50

Для отправки решений необходимо выполнить вход.

www.contester.ru