CSP-S eleven training Day2

greedy 

GDOI 2018 

Given a sequence of length n, a range of [0, m-1] are then each time interval can select a +1, -1 and then find all the numbers into the mold at least 0 m sense required secondary 

The subject is to add a minimum number of times in a modulo sense. You may wish to think about.

Then consider the case without modulo m this is a very classic issues such as school oj that sample item number listed differential problem and this problem requires that we finally put all the numbers become 0

Then we consider the original sequence difference calculated from the first sequence b 1 to n items we simply requires out all positive and negative numbers p and q, and then the final answer is max (p ,, - q)

So in a modulo sense we can become not only can put all the numbers 0 m become all now consider those numbers become digital becomes 0 which will make the whole sequence m minimum number of modifications

Then obviously we can guess is greedy for a small number certainly try to accommodate larger numbers become 0 m so we might as well try to become the b sequence from small to reach the sort

Consider finding a location x st $ b_1, b_2 .... b_x $ 0 then all adjustments to become part of the m [x + 1, n] of our greedy in doing this will find that this is the minimum number of times to find

Is seeking $ max (\ sum_ {i = 1} ^ {x} b_i, \ sum_ {i = x + 1} ^ {n} m-b_i) $ Minimum 

Take the number of games: given a positive integer n not even need to put them in a row composed of a maximum number of integers:

The sample we see this topic always guess a lot of fake greedy so this time we may wish to consider two numbers ab

We are able to compare it on a maximum of every two numbers are compared before before b or b on a big we can get the relative size of each digit

 

 

Guess you like

Origin www.cnblogs.com/Tyouchie/p/11616839.html