QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21066. Bessie の減速

Statistics

Bessie は冬季 Moolympic のクロスカントリースキーに出場しています。初速は毎秒 1 メートルですが、疲れて減速します。減速のたびに速度は下がり、1 回後は毎秒 $1/2$ メートル、2 回後は毎秒 $1/3$ メートル、というようになります。

いつどこで減速するかをイベントで知らせます。次のイベント:

T 17

は特定の時刻、ここでは開始 17 秒後に減速することを表します。次のイベント:

D 10

は開始位置から特定の距離、ここでは 10 メートルで減速することを表します。

$N$ 個のイベント($1 \leq N \leq 10,000$)から 1 キロメートルを進む秒数を求めてください。最も近い整数秒に丸めます(0.5 は 1 に切り上げ)。

入力

標準入力から読み込んでください。

  • 1 行目:$N$。
  • $2..1+N$ 行目:各行は "$T$ $x$" または "$D$ $x$" で、時間または距離のイベントです。どちらも $x$ は整数で、1 キロメートルに達する前のイベントであることが保証されます。同時に複数発生して一度に大きく減速する場合があります。順番に並んでいない場合もあります。

出力

標準出力に書き込んでください。

  • 1 行目:1 キロメートルを進む総時間。

入出力例

入力 1

2
T 30
D 10

出力 1

2970

注記

時刻 $t = 30$ と距離 $d = 10$ で減速します。

最初の 10 メートルは毎秒 1 メートルで 10 秒かかります。毎秒 $1/2$ に減速して次の 10 メートルは 20 秒です。30 秒に達し毎秒 $1/3$ に減速します。残り 980 メートルは $980 * 3 = 2940$ 秒です。総時間は $10 + 20 + 2940 = 2970$ です。

問題作成者:Brian Dean、2014

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.