HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Kovrov IT > problem:


2010.A. 50287 - Providers

Guest
• Discussion of problem (1)

Volume problems

• 2009.B. 50284 - Knights of the Rook
• 2009.C. 50285 - Meat store
• 2009.D. 50259 - Many-coloured roads
• 2009.E. 50266 - Kovrov
• 2009.F. 50267 - Interesting permutat...
• 2009.G. 50260 - What about judges?
• 2009.H. 50268 - Triangles
• 2009.I. 50278 - ATM
• 2010.A. 50287 - Providers
• 2010.B. 50281 - Primes
• 2010.D. 50277 - Unusual Lottery
• 2010.E. 50664 - Polygons
• 2010.F. 50265 - Liars and Knights
• 2010.G. 50256 - Sequence
• 2010.H. 50282 - Coins
• 2010.I. 50257 - Galls village
• 2010.J. 50258 - String manipulations

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 1500/2000/2000/2000 ms. Memory limit 65000/65000/65000/65000 Kb.
Автор: Сергей Виноградов, Ярославль.

There are N providers and M internet users in your town. Every user needs internet, but does not need more than one provider. Every user knows, what providers are available to him. Every provider can accept connections from not more than Ki users. You must find the maximal quantity of users, that can be connected to internet at the same time.

Input
The first line contains two integers N (1 ≤ N ≤ 50) and M (1 ≤ M ≤ 500). The second line contains N numbers Ki (1 ≤ Ki ≤ 50). Each line of next M lines contains a lists of providers, available for corresponding user - a set of nonrepeating numbers from 1 to N, separated by single spaces. List of providers is terminated by zero.

Output
Output one number - maximal quantity of users online.

Input 1 Output 1
2 5
3 2
1 2 0
1 2 0
1 0
1 0
2 0
5

Для отправки решений необходимо выполнить вход.

www.contester.ru