#P2338. Bessie's Cross-Country Skiing Challenge
Bessie's Cross-Country Skiing Challenge
Bessie's Cross-Country Skiing Challenge
Bessie the cow is competing in a cross-country skiing event at the winter Moolympic games. She starts at an initial speed of \(1\) meter per second. However, every time she makes a mistake, her speed decreases. After the first mistake, her speed becomes \(\frac{1}{2}\) meter per second; after the second, it becomes \(\frac{1}{3}\) m/s; and in general after the \(k\)-th mistake, her speed becomes \(\frac{1}{k+1}\) m/s.
There are two types of mistakes (events): one that occurs at a designated time and one at a designated distance. An event of the form T x
means that Bessie makes a mistake at time \(x\) seconds into the race, while an event of the form D x
means that she makes a mistake upon reaching \(x\) meters from the start. Note that if both a time event and a distance event occur at the same moment, they are considered separate mistakes and both affect her speed.
The race finishes after she travels \(1000\) meters. Given a list of \(N\) events (\(1 \le N \le 10,000\)) in arbitrary order, compute the total time in seconds for Bessie to finish the race. Round the answer to the nearest integer second (with 0.5 rounding up).
inputFormat
The first line contains a single integer \(N\), the number of events. Each of the next \(N\) lines contains an event record in one of the following formats:
T x
— a time event occurring at \(x\) seconds.D x
— a distance event occurring at \(x\) meters from the start.
Note that the events can be given in any order.
outputFormat
Output a single integer: the total time in seconds for Bessie to finish \(1000\) meters, rounded to the nearest integer (with 0.5 rounding up).
sample
1
T 500
1500
</p>