QOJ.ac

QOJ

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

#21064. Bessie の減速

Statistics

牛の Bessie は冬季 Moolympic のクロスカントリースキーに参加しています。最初の速度は秒速1メートルですが、時間とともに疲れて減速します。減速のたびに速度が下がり、1回目の後は秒速 $1/2$ メートル、2回目の後は秒速 $1/3$ メートル、以下同様です。

Bessie がいつ、どこで減速するかは、一連のイベントとして与えられます。例えば:

T 17

は特定の時刻、ここでは競技開始から17秒で減速することを意味します。次のイベント:

D 10

はスタートから特定の距離、ここでは10メートルで減速することを意味します。

このようなイベント $N$ 個($1 \leq N \leq 10,000$)が与えられたとき、Bessie が1キロメートルを進むのにかかる秒数を求めてください。最も近い整数秒に丸めます(0.5は1に切り上げます)。

入力

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

  • 1行目:$N$ の値。
  • 2行目から $1+N$ 行目:各行は「$T$ $x$」または「$D$ $x$」で、時間または距離のイベントを表します。どちらでも $x$ は整数で、イベントは Bessie の総走行距離が1キロメートルに達する前に起きることが保証されます。複数のイベントが同時に起き、一度に大きく減速することもあります。イベントは順に並んでいるとは限りません。

出力

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

  • 1行目:Bessie が1キロメートル進むのに必要な合計時間。

入出力例

入力 1

2
T 30
D 10

出力 1

2970

注記

Bessie は時刻 $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.