2 Fast 2 Furious
Practice
3.4 (426 votes)
Ad Hoc
Approved
Basic programming
Easy
Open
Problem
78% Success 13308 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Problem Statement:
Dom and Brian were trying to evade the truck drivers of Verone's gang. They were too fast, too furious for them, and could get away from the truck drivers easily. They decided to race with each other, and divided the city into N checkpoints for the same. Mia was monitoring Dom and Brian throughout the race and she noted down their speeds at every checkpoint.

Roman was jobless, as usual, and told Mia that Dom would definitely have the maximum change in speed between any two consecutive checkpoints. Mia, disagreed with him and challenged him that Brian would have maximum change in speed.

Help Mia and Roman to find out who has the maximum change in speed between any two consecutive checkpoints - Dom or Brian.
Note: Both negative and positive changes have to be considered. Hence, absolute value of maximum change in speed is to be considered.

Input:
First line contains a positive integer N - total number of checkpoints
Second line contains N space-separated integers - ai - the speeds of Dom's car at each checkpoint.
Third line contains N space-separated integers - bi - the speeds of Brian's car at each checkpoint.

Output:
Print who had the maximum change in speed between 2 consecutive checkpoints - Dom or Brian.
If both have equal maximum change in speed, print "Tie".
Print a single integer on a new line - the maximum absolute change in speed between 2 consecutive checkpoints.

Constraints:
2 ≤ N ≤ 106
-109 ≤ ai ≤ 109

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
7 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyHash MapsImplementationString Manipulation
Points:20
27 votes
Tags:
ArraysEasyImplementationMathRecursion
Points:20
31 votes
Tags:
Ad-HocBrute-force searchEasyImplementation