Opening Ceremony
Time limit2sMemory limit512 MB
For each data set, count how many athletes from each country marched, then report the largest shortfall against that country's registered total.
- Level
Easy2 of 10
- Topics
- Array, Implementation, Simulation
- Solved
- No attempts yet
Problem
The Olympic games start with an opening ceremony. The athletes of every participating country march around the main stadium. A country normally marches as one bloc, so the organizers can see at a glance which country has the most athletes missing. Call an athlete who registered but skipped the ceremony to train instead a delinquent.
At this ceremony the athletes marched mixed together, in no country order. Counting now means reading every jersey and keeping a separate tally per country.
You are given how many athletes each country registered, followed by the country of every athlete who marched, in order. Find the largest number of delinquents of any country.
Input
The first line contains the number of data sets , with . Then follow data sets in this format.
The first line of a data set contains two integers and . Here is the number of participating countries with , and is the number of athletes who marched in the ceremony with .
The next line contains integers . Here is the number of athletes registered for country , with .
The next line contains integers . Here is the country of the -th athlete who marched, with . This line is empty when is 0. No country ever sends more than athletes to the ceremony.
Output
For each data set, first print Data Set x: on a line by itself, where is the number of the data set counting from 1. On the next line print the largest number of delinquents of any country in that data set.
Print a blank line after each data set.