• [B] Beautiful Walls

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • To simplify the building process, XadillaX built some template on the ground. The template is a very big wall and the height of each unit may be different.

    8Mao and Hungar have to choose any part of this wall as their own wall.

    The part(i, j) means the wall between unit(i) and unit(j) with their heights.
    What Hungar thinks a beautiful wall is that the height of each unit is unique.
    Now give you a wall-template, you should tell Hungar that how many ways he can choose to copy his own wall?
  • 输入
  • This problem contains several cases, ends with EOF.
    The first line of each case is one integer N (0 < N ≤ 100000) which indicates the side length (number of units) of the wall-template.
    The second line contains N integers which indicate the height of each unit. (0 < height <= 100000)
  • 输出
  • For each case, you should output the number of ways that Hungar can choose.
  • 样例输入
  • 5
    3 4 5 5 2
    3
    1 2 3
    
  • 样例输出
  • 9
    6
    
  • 提示
  • 来源
  • cjl
  • 操作

显示春菜