P2338 [USACO14JAN] Bessie Slows Down S

Description

Bessie the cow is competing in a cross-country skiing event at the winter Moolympic games. She starts out at a speed of 1 meter per second. However, as she becomes more tired over time, she begins to slow down. Each time Bessie slows down, her speed decreases: she moves at 1/2 meter per second after slowing down once, then 1/3 meter per second after slowing down twice, and so on. You are told when and where Bessie slows down, in terms of a series of events. An event like this: T 17 means that Bessie slows down at a specific time -- here, 17 seconds into the race. An event like this: D 10 means that Bessie slows down at a specific distance from the start -- in this case, 10 meters. Given a list of N such events (1

Input Format

第一行:单个整数 $N$,$1\le N\le10000$。 第二行到第 $N+1$ 行:每行开头有一个大写字母,代表贝西的一个失误类型: - 如果是 `T`,接下来会有一个整数 $S$,表示在比赛开始后的第 $S$ 秒钟整发生了一次失误,$1\le S\le10^7$。 - 如果是 `D`,接下来会有一个整数 $X$,表示在距离起点 $X$ 米处发生了一次失误,$1\le X\le1000$。

Output Format

单个整数:表示贝西需要多少秒才能滑到终点,如果精确的时间不是整数,则用四舍五入的方法向最接近的整数取整。

Explanation/Hint

样例解释: 前 $10$ 秒,贝西的速度是每秒 $1$ 米,她滑了 $10$ 米。然后她遭遇了第一次失误,在接下来的 $20$ 秒内,她又滑了 $10$ 米。之后她遭遇了第二次失误,还剩下 $980$ 米,所以她共计花去 $10+20+2940=2970$ 秒才完成比赛。