Counting Friends
의견: 0
Farmer John's N cows (2 <= N <= 500) have joined the social network "MooBook".
Each cow has one or more friends with whom they interact on MooBook. Farmer John makes a list of the number of friends for each of his cows, but during the process he becomes distracted, and he includes one extra number by mistake (so his list contains N+1 numbers, instead of N numbers as he intended).
Please help Farmer John figure out which numbers on his list could have been the erroneous extra number.
Line 1: The integer N.
Lines 2..2+N: Line i+1 contains the number of friends for one of FJ's cows, or possibly the extra erroneous number.
Line 1: An integer K giving the number of entries in FJ's list that could be the extra number (K=0 means no number's removal yields a feasible pairing).
Lines 2..1+K: Each line contains the index (1..N+1) within the input ordering of a number that could potentially be the extra number, in sorted order.
fcount.infcount.out4
1
2
2
1
33
1
4
5Output details: Removing the first "1", the other "1", or the "3" each yields a list admitting a feasible friendship pairing.
평가 및 의견
Counting Friends
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Counting Friends