Mouse Pursuit
InterviewTime limit3sMemory limit2048 MB
Given n events, each a caught or missed mouse with a time offset and cheese and glory changes, find the totals gained in the last k seconds.
- Level
Medium4 of 10
- Topics
- Prefix sum, Sorting, Binary search
- Solved
- No attempts yet
Problem
Brandon is playing the newest idle game, Mouse Pursuit. The goal of this game is to pursue mice for cheese and glory.
In Mouse Pursuit, an event consists of pursuing a mouse. If the mouse is caught, the player might earn cheese and glory. If the mouse is not caught, the player might lose cheese and glory.
Given Brandon's recent events, find how much cheese and glory Brandon earned in the last seconds.
Input
The first line of input contains a single integer .
The next lines take one of two forms:
- CAUGHT : A mouse was caught exactly seconds ago. The player gained pieces of cheese and units of glory.
- MISS : A mouse was missed exactly seconds ago. The player lost pieces of cheese and units of glory.
For all events, and . No two events happened at exactly the same time.
The last line contains a single integer . No event happened exactly seconds ago.
Output
Output two integers: the number of pieces of cheese Brandon gained in the last seconds, and the number of units of glory Brandon gained in the last seconds.