1774 - I2P(I)2019_Yang_CS_lab4 Scoreboard

Time

2019/10/08 18:30:00 2019/10/08 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12399 Beautiful Number
12427 AAAAdd

12399 - Beautiful Number   

Description

Let’s define an array element arr[i] is beautiful if there’s no element before arr[i] is greater than arr[i].In the other words, if arr[i] is beautiful, then arr[iarr[j] is false for all ≤ i.

Your task is to find the largest beautiful element.

 

Hints:The variable used to record largest beautiful element should be initialized small enough

 

Input

The first line contains an integer N, meaning the size of array. The second line contains N integers, denoting each element in array.

  • 1 <= n <= 1000
  • 1 <= array elements <= 100000

Output

Print the largest beautiful element.
Remember to print ‘\n’ on the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12427 - AAAAdd   

Description

The input contains nine different numbers, which are 1 to 9 in some random order, for example, 4 1 5 9 8 7 3 6 2. Now, start from the first place, we get the number 4. It indicates that the next number we need to pick is at the 4th place, which is 9. Likewise, we then go the 9th place and get the number 2. We repeat this process until we go to a place that has already been visited. In this example, we will stop at the second place and get the number 1, because we have found a circle. Therefore, along the way we pick four numbers, 4 9 2 1, and the output is the sum of these numbers, which is 16.
Note that we always start from the first place.
Other examples: Consider the input 2 3 4 5 6 7 8 9 1, the output should be 45 since we will visit the numbers one by one and go back to the beginning. Consider the input 1 9 8 7 6 5 4 3 2, the output should be 1 since we stop immediately and cannot go anywhere. Consider the input 9 2 3 4 5 6 7 8 1, the output should be 10.

Input

A random sequence of the nine different numbers of 1 to 9.

Output

The sum of the numbers being visited. Remember to print a '\n' at the end of the sum.

Sample Input  Download

Sample Output  Download

Tags




Discuss