Driving in the Mountains
InterviewTime limit1sMemory limit1024 MB
Given ground heights and Juta's height changes per meter, output whether she is on the ground, on a viaduct, or in a tunnel after each meter.
- Level
Easy3 of 10
- Topics
- Implementation, Prefix sum
- Solved
- No attempts yet
Problem
Juta visited Norway, which has many mountains. Her smartphone recorded how her trip went up and down. Every meter, the phone reported how many units she moved up or down. Juta started her trip on the ground, but sometimes she drove along a viaduct above the ground or through a tunnel below it. You are given the height of the ground above sea level along Juta's trip and the notifications from her phone. For each meter, find whether Juta was on the ground, in the air on a viaduct, or underground in a tunnel at that moment.
Input
The first line contains an integer , the length of the trip in meters (). The second line contains integers (), the height of the ground above sea level at the start of the trip and after each meter. The third line contains integers (), where is how much Juta's height changed during the -th meter. You may assume Juta's height above sea level never leaves the range to .
Output
Print a single line of characters. The -th character tells where Juta is after passing the -th meter: 'M' for the ground, 'V' for a viaduct in the air, or 'T' for a tunnel underground.