Asusual,Serejahasarray a,itselementsareintegers: a[1], a[2], ..., a[n].Let'sintroducenotation:Aswapoperationisthefollowingsequenceofactions:choosetwoindexes i, j (i ≠ j);performassignments tmp = a[i], a[i] = a[j], a[j] = tmp.Whatmaximumvalueoffunction m(a) canSerejagetifheisallowedtoperformatmost k swapoperations?InputThefirstlinecontainstwointegers n and k (1 ...
'Jeopardy!'isanintellectualgamewhereplayersanswerquestionsandearnpoints.CompanyQconductsasimplified'Jeopardy!'tournamentamongthebestITcompanies.Byaluckycoincidence,theoldrivalsmadeittothefinals:companyR1andcompanyR2.Thefinalswillhave n questions, m ofthemareauctionquestionsand n - m ofthemareregularquestions.Eachquestionhasaprice.Thepriceofthe i-thquestionis ai points.Durin...
DescriptionFarmerJohnhasaproblem:thedirtroadfromhisfarmtotownhassufferedintherecentrainstormsandnowcontains(1<=N<=10,000)mudpools.FarmerJohnhasacollectionofwoodenplanksoflengthLthathecanusetobridgethesemudpools.Hecanoverlapplanksandtheendsdonotneedtobeanchoredontheground.However,hemustcovereachpoolcompletely.Giventhemudpools,helpFJfigureouttheminimumnumberofplanksheneedsinorderto...
DescriptionThecowsaregoingtospace!Theyplantoachieveorbitbybuildingasortofspaceelevator:agianttowerofblocks.TheyhaveK(1<=K<=400)differenttypesofblockswithwhichtobuildthetower.Eachblockoftypeihasheighth_i(1<=h_i<=100)andisavailableinquantityc_i(1<=c_i<=10).Duetopossibledamagecausedbycosmicrays,nopartofablockoftypeicanexceedamaximumaltitudea_i(1<=a_i<=40000).Helptheco...
近期评论