A
=w=
B
VOV
C
QoQ
D
Test instructions: Beleriand winter is very cold, then the driver to change the winter special tires to drive. Suppose there is a total of n days in winter, a set of winter special tires, only can use K days, the tires no matter what temperature can be used, and the summer tires can only be used in the days of non-negative temperature, ask to safely open n days of the car need to change the minimum number of tires (put on and take off the count)
Analysis: Greed
Greedy idea is very good, according to the length of the successive summer to sort, small first to fill
But pay attention to two paragraphs.
If the first part of the summer is filled, the result is not optimal, so the beginning is assumed to be placed at the end of the interval array
As for the last summer, it is very awkward, that is, the other interval if filled, the contribution to the result is-2, and the last interval contribution is-1, which involves the value and cost problems, so there are two possibilities, one is to put the final interval in the front interval sort, One is to place the last interval in the penultimate (the first is the first interval), to compare the minimum output of the two cases
In a wonderful posture a this problem, looking forward to a more orthodox greedy
E
Test instructions: gives you a way to construct a tree that allows you to output the tree in depth
Analysis: Simulation
It's just a simulation, similar to manipulating infix expressions.
Codeforces Round #387 (Div 2)