Happy Jizhong (b) 2

 Another day of autistic, but fortunately questions booked
me. . .

T1, [meal] (http://jzoj.net/senior/#contest/show/2823/0)

Food is very tasty dish of meaning, food is the most important to choose a good raw material.
  There are N kinds of ingredients, each of both acidity and S B Bitterness two attributes, when selecting a variety of materials, a total acidity of the acidity of the product of each ingredient, the total degree of bitterness Bitterness of each ingredient with.
  As you know, neither food nor bitter acid, as a raw material to ensure that the selected total acidity and total pain of the minimum absolute difference.
  Because food is not only water, so you must select at least one meal.

Persevering, n-10 only so much water may be too method, only 10 minutes cut.

T2 [fetch game] (http://jzoj.net/senior/#contest/show/2823/1)


Alice wants Bob to accompany him to see "the Great Tangshan Earthquake", but because Bob is a very emotional person, fear do not want to cry, but I am sorry this as a reason to refuse, they proposed to play a game.
  N positive integers circle, rules are as follows:
  • two players take turns fetching;
  • the beginning just get a player can take any number x;
  • the beginning of the current player can only take x from the second step (the player just take a number) left and right sides of adjacent numbers;
  • take complete until all the numbers, the game is over;
  • get more odd number of wins.
  Bob in order to show generosity, let Alice first take, but he forgot himself and Alice are very smart people, Alice now ask you to help him calculate how many emulated the first step in making the final victory.

This problem is a simple game plus the interval dp it. .

Recording a prefix and an odd number of s, and then enumerate the first holding position, for DP. 3 ^ n-,

K starting, i is the left end point, j is the right end,


`` `CPP
for(int i=k+n;i>=k+1;i--){
for(int j=i+1;j<=k+n+1;j++){
f[i][j]=s[j]-s[i-1]-min(f[i+1][j],f[i][j-1]);
}
}

if(s[k+n]-s[k]-f[k+1][k+n-1]>f[k+1][k+n-1])ans++;

```

T3 [Delete] (http://jzoj.net/senior/#contest/show/2823/2)

 Alice on chemical class and distracted, he first drew a line 3 of Form N columns, then the first row of numbers 1 to N fill in the form, to ensure that each number appears only once, while he also filled two rows numbers 1 to N, but not limit the number of occurrence of each number.
  Alice now want to delete several columns so that each row after row of identical sequence finished, the program requires a minimum of computing how many columns to delete.

A seemingly greedy title is actually a mathematical conclusion,

According to the meaning of the questions, delete columns, so that the number of the remaining three lines of the same set,

Set a, b, c columns

Because, when b or c with a repeating elements, the missing number of elements will,

So only need each iteration, delete c, b is not, but some of the elements in a column where.

T4 [section] (http://jzoj.net/senior/#contest/show/2823/3)

Alice received some very special birthday gift: interval. Even if it is boring, Alice was able to come up with a lot of games on intervals, one of which is, Alice longest sequence selected from different sections, where each section must meet the gift, the other in the sequence must contain at each interval an interval.
  Program calculated maximum length sequence.

Nlogn solution does not drop the longest sub-sequence (binary search queue and maintenance updates.)

Guess you like

Origin www.cnblogs.com/you-xiao-mang-ci/p/11291527.html