All problems

A Four-Panel Summary Report

hardPythonMatplotlibDashboard

Kestrel Freight closes each month with a one-page report: a trend panel for the daily figures, a bar panel and a share panel for the service types, and a distribution panel for the daily figures again. The covering email carries two lines of text so the report can be read on a phone — how much the month moved overall, and which service type led it.

Task: Print the month's overall move and the largest service type.

Input

Four parts. The first line holds one integer n, the number of days. The second line holds n daily figures separated by single spaces. The third line holds one integer k, the number of service types. Each of the next k lines holds a service type name and its figure, separated by a single space. Names contain no spaces.

Output

Two lines. The first is the last daily figure measured against the first, so a month that ended lower prints a negative number, and a month that ended level prints 0.0. It is a plain decimal, so a whole move prints with one decimal place. The second is the name of the service type with the largest figure; if two tie, print whichever appeared first.

Example:

Input:
3
100 110 130
2
A 60
B 40

Output:
30.0
A

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…