403106: GYM101005 I Substring

Memory Limit:64 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Substringtime limit per test0.65 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

Given an array of positive integers, count the number of substrings with the following properties:

  • it has length of at least 2
  • its extremities are bigger than the other elements (e.g. 2 2 3 is bad, but 3 2 3 is good)
Input

The input will contain on the first line one integer (. The second line contains numbers and the array for which we want the solution is obtained as following: . Both arrays and are 0-indexed.

Output

The output will contain the number of substrings with the given properties.

ExampleInput
3
3 2 3
Output
2

加入题单

上一题 下一题 算法标签: