QOJ.ac

QOJ

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

#21064. Bessie 減速

Statistics

乳牛 Bessie 正參加冬季 Moolympic 運動會的越野滑雪比賽。她最初的速度為每秒 1 公尺。隨著時間推移,她越來越疲憊,開始減速。每次減速後,她的速度都會下降:第一次減速後為每秒 $1/2$ 公尺,第二次後為每秒 $1/3$ 公尺,依此類推。

你會透過一系列事件得知 Bessie 何時、何處減速。例如:

T 17

表示 Bessie 在特定時刻減速,這裡是比賽開始後的 17 秒。這樣的事件:

D 10

表示 Bessie 在距離起點特定距離的位置減速,這裡是 10 公尺。

給定 $N$ 個這樣的事件($1 \leq N \leq 10,000$),計算 Bessie 走完整整一公里所需的秒數。將答案四捨五入到最接近的整數秒(0.5 向上捨入為 1)。

輸入格式

從標準輸入讀取。

  • 第 1 行:$N$ 的值。
  • 第 2 至 $1+N$ 行:每行為「$T$ $x$」或「$D$ $x$」,表示時間事件或距離事件。兩種情況下,$x$ 都是整數,保證事件發生在 Bessie 總路程達到一公里之前。多個事件可能同時發生,導致 Bessie 一下子減速多次。事件不一定按順序給出。

輸出格式

寫入標準輸出。

  • 第 1 行:Bessie 走完一公里所需的總時間。

範例

輸入格式 1

2
T 30
D 10

輸出格式 1

2970

說明

Bessie 在時刻 $t = 30$ 和距離 $d = 10$ 處減速。

Bessie 以每秒 1 公尺走前 10 公尺,用時 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.