Up, Down, or Flat?
The line at the top of Meridian's monthly pack has to say whether trade is going up, going down, or doing neither. The owner's rule splits the run down the middle and holds the second half's average against the first half's, with a band around the middle so that ordinary wobble is not reported as a trend. Runs always contain an even number of days.
Task: Print the one-word verdict.
Input
The first line holds an integer n, always even. Each of the next n lines holds one day's takings, always greater than zero.
Output
One line holding one word. Print up when the second half's average is more than 5% above the first half's, down when it is more than 5% below, and flat in every other case. The 5% is measured against the first half's average, and a gap of exactly 5% counts as flat.
Example:
Input:
4
1
2
9
10
Output:
up
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in