• [1289] Will TT Get Snacks?

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Mr. Cai and TT were playing in a beautiful sandy beach, and TT discovered a tree branch with many ant walking on it.

    TT noticed that when one ant meet another, they would turn back and keep on walking, when an ant walk straight to the side of the branch and there is no block on it's road(if exist, this ant will meet another and turn back,then it can't walk out the branch), it will walk out the branch and disappear. Mr.Cai also noticed this, he said:"TT, if you tell me how long will all the ants disappear and how long is the first ant walked out, I'll buy you many many snacks as praise."


  • 输入
  • There are many cases. First there are two integers len and n, means the length of the branch and the number of the ant.then followed n lines, the ith line includes the ith ant's position to the left side and it's position. Suppose all the ants walk 1m/s, and no time will waste in every meet or turn back.
  • 输出
  • For each case, output the maximun time these ants spent and the mininum time the first ant walked out.
  • 样例输入
  • 20 3
    3 l
    12 r
    7 r
  • 样例输出
  • max = 13
    min = 3
  • 提示
  • 来源
  • Mr. Cai
  • 操作

显示春菜