+ 10.2 greedy bipartite

T1

problem

To a snowman snowball need three different sizes. Now there are n Snowball given size, ask how many snowmen can pile up.

years

First with the largest number of balls, such as \ (100,1,1,1,1 \) . If you take the first \ (1,1,1 \) , can only be a heap, but if you use the \ (100 \) in one, you can stack two multi must first use. so as long as statistics + ordering it.

T2

problem

Supermarket discount. If the shopping cart least a stool, you can buy half-price shopping cart the cheapest item. Now you want to buy the n items, some of which are stools. K you have a shopping cart, find an optimal shopping program makes the least expensive.

years

The maximum discount stool can only be favorable to himself. Because it is assumed a cart in the stool is not the most expensive, it can only offer a stool. If the stool is the most expensive, the result will only be more bad. So before the \ (k-1 \) before your stool into the \ (k-1 \) a shopping cart, and the rest all packed in a shopping cart.

T3

problem

With n Rohan, Rohan has weight w and each s strength
defines a dangerous value Rohan weight value and subtracting all of the above items his power. Arrange a sequence such that the minimum value of maximum risk Rohan dangerous values.

years

Item exchange with adjacent a conclusion according to \ (w_i + s_i \) ascending sequential ordering optimum results.

T3

problem

[JSOI2007] base, there are n the building received a serious injury, but only a maintenance worker. Repair a building needs \ (t_i \) time, a worker can only repair, if a building in \ (b_i \) there is no time to fix it scrapped. called for a reasonable order to repair more buildings.

years

According to the first d from small to large, middle do to change the decision. Through all the building i, if they can repair to repair.

If not, then find the largest building in the previously time-consuming restoration of the building, back in time, if the building takes longer than this, that it would give up, alterations to this. Equivalent to the same number of building repair, the total time used the shortest. back in time can be achieved by a large heap root.

T4

problem

[GDOI2018 D1T2] Given a [1 ... n], a_i \ in [0, m-1], for each operation can be any interval [l, r] in the overall sense% m -1 or +1 , It requires at least several operations may be such that all digits become zero.

years

To a maintain a differential array, our goal is to become a full array of differential range 0.5 plus or minus into a plus or minus endpoint. A positive number corresponds to a negative number. If the sum is a positive number A, and the negative is B, then the result is \ (max (A, | B |) \) .

T5

problem

Given a maximum of 240 large integer S, wherein any N digital removed, so that the remaining digits of a new positive integer S '. For a given N and S, to find a solution so that the remaining digits the number of new S 'minimum.

years

Sweep from front to back, if it has been incremented delete the last number. If you put the inflection point of diminishing delete appears, and then start from scratch again sweep again.

T6

problem

The entire positive integer n, it is necessary to connect them in a row, a set of the largest whole number integer.

years

T7

problem

Given an n points rooted tree, there is a [x] cherry flowers on each point x, provided fa [x] represents a father, son [fa [x]] represents the number of father's son can now delete after some nodes, then the deleted node cherry will be added to the father, son, it will be connected to the father. requires complete deletion x, fa [x] + count of the number of cherry fa [x] son ​​<M. Q the maximum number of points can be deleted.

years

Bottom-up delete, delete every son of a [x] + son [x] smallest one, so that the smallest increment on their own. Bottom-up more conducive to delete. But also to try to delete delete. Because for a point and its father, can only remove one of them. If you delete a father, grandfather would result in an increase of the key, and delete their own would not be more conducive to the upper point is deleted.

T8

problem

N has a given point m to FIG edge, and to ensure that the front edge of the n-1 to define a configuration is the root of the tree .T-simple dfs is at most one edge of this tree is not a ring. Asked at least select how many T-simple edge such that each have at least one edge is selected.

years

Because this is a number dfs, so in addition to the side of the tree diagram only the atavistic side.

First look at a child, if it is a sequence of a plurality of intervals required to be selected, then sweep from front to back, right click on the point in the interval to the non-selected, so the conversion problem is similar to a tree.

T9

problem

A given number of columns M in reverse order, to obtain a minimal sequence lexicographically larger than the original, but also to reverse the column number M .N <= 5e6.

years

Guess you like

Origin www.cnblogs.com/i-cookie/p/11617424.html