Pashmak'shomeworkisaproblemaboutgraphs.Althoughhealwaystriestodohishomeworkcompletely,hecan'tsolvethisproblem.Asyouknow,he'sreallyweakatgraphtheory;sotrytohelphiminsolvingtheproblem.Youaregivenaweighteddirectedgraphwith n verticesand m edges.Youneedtofindapath(perhaps,non-simple)withmaximumnumberofedges,suchthattheweightsoftheedgesincreasealongthepath.Inotherwords,eachedgeofthepathmustha...
Alexdoesn'tlikeboredom.That'swhywheneverhegetsbored,hecomesupwithgames.Onelongwintereveninghecameupwithagameanddecidedtoplayit.Givenasequence a consistingof n integers.Theplayercanmakeseveralsteps.Inasinglestephecanchooseanelementofthesequence(let'sdenoteit ak)anddeleteit,atthatallelementsequalto ak + 1 and ak - 1 alsomustbedeletedfromthesequence.Thatstepbrings ak pointstothe...
PrincessTwilightwenttoCelestiaandLuna'soldcastletoresearchthechestfromtheElementsofHarmony.Asequenceofpositiveintegers bi isharmonyifandonlyifforeverytwoelementsofthesequencetheirgreatestcommondivisorequals1.Accordingtoanancientbook,thekeyofthechestisaharmonysequence bi whichminimizesthefollowingexpression:Youaregivensequence ai,helpPrincessTwilighttofindthekey.InputThefirstlinec...
DescriptionBessieandBonniehavefoundatreasurechestfullofmarvelousgoldcoins!Beingcows,though,theycan'tjustwalkintoastoreandbuystuff,soinsteadtheydecidetohavesomefunwiththecoins.TheN(1<=N<=5,000)coins,eachwithsomevalueC_i(1<=C_i<=5,000)areplacedinastraightline.BessieandBonnietaketurns,andforeachcow'sturn,shetakesexactlyonecoinoffofeithertheleftendortherightendoftheline.Thegame...
DescriptionFarmerJohn'scows,pamperedsincebirth,havereachednewheightsoffastidiousness.Theynowrequiretheirbarntobeimmaculate.FarmerJohn,themostobligingoffarmers,hasnochoicebuthiresomeofthecowstocleanthebarn.FarmerJohnhasN(1<=N<=10,000)cowswhoarewillingtodosomecleaning.Becausedustfallscontinuously,thecowsrequirethatthefarmbecontinuouslycleanedduringtheworkday,whichrunsfromsecondnumbe...
DescriptionFarmerJohnhasreturnedtotheCountyFairsohecanattendthespecialevents(concerts,rodeos,cookingshows,etc.).HewantstoattendasmanyoftheN(1<=N<=10,000)specialeventsashepossiblycan.He'srentedabicyclesohecanspeedfromoneeventtothenextinabsolutelynotimeatall(0timeunitstogofromoneeventtothenext!).GivenalistoftheeventsthatFJmightwishtoattend,withtheirstarttimes(1<=T<=100,000)a...
Youhave k piecesoflaundry,eachofwhichyouwanttowash,dryandfold.Youareatalaundromatthathas n1 washingmachines,n2 dryingmachinesand n3 foldingmachines.Eachmachinecanprocessonlyonepieceoflaundryatatime.Youcan'tdryapieceoflaundrybeforeitiswashed,andyoucan'tfolditbeforeitisdried.Moreover,afterapieceoflaundryiswashed,itneedstobeimmediatelymovedintoadryingmachine,andafteritisdried,itneedstobei...
近期评论