题目大意是有n个人参加舞会,第i个人希望认识a[i]个朋友,初始每个人都没有朋友,问能否满足所有人的交友要求。
显然a[i]>=n,a[i]>=total(大于0的a[i]总数)以及∑a[i] mod 2<>0的可直接判无解。然后每次都按照交友量需求进行排序,从大到小分配,如果遇到无法分配的则可判无解。注意一定要保证每次分配的顺序都是从大到小,否则会WA。维护队列的有序性可以用Qsort也可以用堆,虽然建堆是线性的,但维护队列过程中的插入和删除操作使总的复杂度还是达到了O(nlogn),所以用Qsort和用堆来维护队列的时间复杂度是相同的,编程复杂度Qsort更加简单。
3016349 2008-08-01 11:55:49 Accepted 2140 FPC 00:00.13 424K IwfWcf@LZOI
coach factory outlet
回复删除mbt shoes women
moncler outlet uk
michael kors outlet online
gucci outlet
steelers jerseys
cheap ugg boots
coach outlet online
cheap ray bans
true religion jeans
201612.26chenjinyan
coach outlet
回复删除golden goose outlet
nike react
curry 4
nike foamposite
longchamp
ralph lauren uk
jordan shoes
hermes handbags
jordan retro
hermes online
回复删除supreme
coach handbags
golden goose
kevin durant shoes
kd shoes
vapormax
Kanye West shoes
off white hoodie
yeezy
click to read morelook here have a peek herego to website weblinkMore Bonuses
回复删除discover this websites my website their explanation view it now click to read
回复删除