• 「CF444A」DZY Loves Physics

    「CF444A」DZY Loves Physics

    DZYlovesPhysics,andheenjoyscalculatingdensity.Almosteverythinghasdensity,evenagraph.Wedefinethedensityofanon-directedgraph(nodesandedgesofthegraphhavesomevalues)asfollows:where v isthesumofthevaluesofthenodes, e isthesumofthevaluesoftheedges.OnceDZYgotagraph G,nowhewantstofindaconnectedinducedsubgraph G' ofthegraph,suchthatthedensityof G' isaslargeaspossible.Aninducedsubgrap...

    02014年7月7日4,016贪心
  • 「BZOJ3399」[Usaco2009 Mar] Sand Castle城堡

    「BZOJ3399」[Usaco2009 Mar] Sand Castle城堡

    Description约翰用沙子建了一座城堡.正如所有城堡的城墙,这城墙也有许多枪眼,两个相邻枪眼中间那部分叫作“城齿”.    城墙上一共有N(1≤N≤25000)个城齿,每一个都有一个高度Mi.(1≤尬≤100000).现在约翰想把城齿的高度调成某种顺序下的Bi,B2,…,BN(I≤Bi≤100000). -个城齿每提高一个单位的高度,约翰需要X(I≤X≤100)元;每降低一个单位的高度,约翰需要Y(1≤y≤100)元.    问约翰最少可用多少...

    02014年7月5日2,965贪心
  • 「BZOJ2430」[POI2003] Chocolate

    「BZOJ2430」[POI2003] Chocolate

    Description有一块n*m的矩形巧克力,准备将它切成n*m块。巧克力上共有n-1条横线和m-1条竖线,你每次可以沿着其中的一条横线或竖线将巧克力切开,无论切割的长短,沿着每条横线切一次的代价依次为y1,y2,…,yn-1,而沿竖线切割的代价依次为x1,x2,…,xm-1。例如,对于下图6*4的巧克力,我们先沿着三条横线切割,需要3刀,得到4条巧克力,然后再将这4条巧克力沿竖线切割,每条都需要5刀,则最终所花费的代价为y1+y2+y3+4*(x1+x2...

    02014年6月20日2,922贪心
  • 「CF442C」Artem and Array

    「CF442C」Artem and Array

    Artemhasanarrayof n positiveintegers.Artemdecidedtoplaywithit.Thegameconsistsof n moves.Eachmovegoeslikethis.Artemchoosessomeelementofthearrayandremovesit.Forthat,hegetsmin(a, b) points,where a and b arenumbersthatwereadjacentwiththeremovednumber.Ifthenumberdoesn'thaveanadjacentnumbertotheleftorright,Artemdoesn'tgetanypoints.Aftertheelementisremoved,thetwopartsofthearraygluetoge...

    22014年6月20日3,692贪心
  • 「CF437B」The Child and Set

    「CF437B」The Child and Set

    Atthechildren'sday,thechildcametoPicks'shouse,andmessedhishouseup.Pickswasangryathim.Alotofimportantthingswerelost,inparticularthefavoritesetofPicks.Fortunately,Picksrememberssomethingabouthisset S:itselementsweredistinctintegersfrom 1 to limit;thevalueof  wasequalto sum;here lowbit(x) equals 2k where k isthepositionofthefirstoneinthebinaryrepresentationof x.Forexample, low...

    02014年6月3日2,801贪心
  • 「CF437C」The Child and Toy

    「CF437C」The Child and Toy

    OnChildren'sDay,thechildgotatoyfromDelayyyasapresent.However,thechildissonaughtythathecan'twaittodestroythetoy.Thetoyconsistsof n partsand m ropes.Eachropelinkstwoparts,buteverypairofpartsislinkedbyatmostonerope.Tosplitthetoy,thechildmustremoveallitsparts.Thechildcanremoveasinglepartatatime,andeachremoveconsumeanenergy.Let'sdefineanenergyvalueofpart i as vi.Thechildspend vf1 + ...

    02014年6月1日619贪心
  • 「CF435B」Pasha Maximizes

    「CF435B」Pasha Maximizes

    Pashahasapositiveinteger a withoutleadingzeroes.Todayhedecidedthatthenumberistoosmallandheshouldmakeitlarger.Unfortunately,theonlyoperationPashacandoistoswaptwoadjacentdecimaldigitsoftheinteger.HelpPashacountthemaximumnumberhecangetifhehasthetimetomakeatmost k swaps.InputThesinglelinecontainstwointegers a and k (1 ≤ a ≤ 1018; 0 ≤ k ≤ 100).OutputPrintthemaximumnumbert...

    02014年5月31日4,399贪心
  • 「BZOJ1707」[Usaco2007 Nov] tanning分配防晒霜

    「BZOJ1707」[Usaco2007 Nov] tanning分配防晒霜

    Description奶牛们计划着去海滩上享受日光浴。为了避免皮肤被阳光灼伤,所有C(1<=C<=2500)头奶牛必须在出门之前在身上抹防晒霜。第i头奶牛适合的最小和最大的SPF值分别为minSPF_i和maxSPF_i(1<=minSPF_i<=1,000;minSPF_i<=maxSPF_i<=1,000)。如果某头奶牛涂的防晒霜的SPF值过小,那么阳光仍然能把她的皮肤灼伤;如果防晒霜的SPF值过大,则会使日光浴与躺在屋里睡觉变得几乎没有差别。...

    02014年5月28日3,177贪心
  • 「BZOJ1828」[Usaco2010 Mar] balloc 农场分配

    「BZOJ1828」[Usaco2010 Mar] balloc 农场分配

    DescriptionInput第1行:两个用空格隔开的整数:N和M*第2行到N+1行:第i+1行表示一个整数C_i*第N+2到N+M+1行:第i+N+1行表示2个整数A_i和B_iOutput*第一行:一个整数表示最多能够被满足的要求数SampleInput541321313252345SampleOutput3题解贪心,按照右端点排序以后冲突的舍弃[crayon-67a3c411a8c92163759860/] ...

    02014年5月28日4,002贪心,线段树
  • 「BZOJ1634」[Usaco2007 Jan] Protecting the Flowers 护花

    「BZOJ1634」[Usaco2007 Jan] Protecting the Flowers 护花

    DescriptionFarmerJohnwenttocutsomewoodandleftN(2<=N<=100,000)cowseatingthegrass,asusual.Whenhereturned,hefoundtohishorrorthatthecowswereinhisgardeneatinghisbeautifulflowers.Wantingtominimizethesubsequentdamage,FJdecidedtotakeimmediateactionandtransportthecowsbacktotheirbarn.EachcowiisatalocationthatisTiminutes(1<=Ti<=2,000,000)awayfromthebarn.Furthermore,whilewaitingfortra...

    52014年5月24日4,027贪心
  • 「BZOJ1629」[Usaco2007 Demo] Cow Acrobats

    「BZOJ1629」[Usaco2007 Demo] Cow Acrobats

    DescriptionFarmerJohn'sN(1<=N<=50,000)cows(numbered1..N)areplanningtorunawayandjointhecircus.Theirhoofedfeetpreventthemfromtightropewalkingandswingingfromthetrapeze(andtheirlastattemptatfiringacowoutofacannonmetwithadismalfailure).Thus,theyhavedecidedtopracticeperformingacrobaticstunts.Thecowsaren'tterriblycreativeandhaveonlycomeupwithoneacrobaticstunt:standingontopofeachothertoform...

    02014年5月23日3,629贪心
  • 「432C」Prime Swaps

    「432C」Prime Swaps

    Youhaveanarray a[1], a[2], ..., a[n],containingdistinctintegersfrom 1 to n.Yourtaskistosortthisarrayinincreasingorderwiththefollowingoperation(youmayneedtoapplyitmultipletimes):choosetwoindexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) isaprimenumber);swaptheelementsonpositions i and j;inotherwords,youareallowedtoapplythefollowingsequenceofassignments: tmp = a[i], a...

    02014年5月21日2,914贪心,筛法