• [1557] Team of Slime

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Today 8Mao got some Slime's eggs. And he hatched some Slimes.

    But the problem is - the size of each Slime is all different!
    For there're N Slimes and 8Mao numbered them from 1 ~ N by their height.
    At first these N Slimes stand at a line and without order of height.
    8Mao wants them to stand at a line from low to high. But there's a rule, 8Mao only can take one of them to the head of the line each step.
    Can you tell 8Mao the minimum steps that he can let Slimes stand from low to high?

  • 输入
  • This problem contains several cases, ends with EOF.
    The first line of each case contains one integer N (1 <= N <= 300, 000) indicates the number of Slimes at the line.
    Next follow N lines which each line indicates the height of Slimes in the initial order.
  • 输出
  • For each case, you should output the minimum steps 8Mao should do.
  • 样例输入
  • 4
  • 样例输出
  • 2
  • 提示
  • 来源
  • cjl
  • 操作