1050 Loop Array Maximum sub-segment and base time limit: 1 second space limit: 131072 KB Score: 10 Difficulty: 2-level algorithm topic collection concerns the cyclic sequence consisting of n integers a[1],a[2],a[3],..., a[n], the sequence as a[i]+a[i+1]+...+a[j] Continuous sub-segments and the maximum value (the loop sequence is the number of n is enclosed in a circle, so you need to consider a sequence such as a[n-1],a[n],a[1],a[2]). When the given integer is a negative number and is 0. For exa
Test Instructions: give a graph containing N points M (may not be connected or include a ring), each point is labeled with a lowercase letter number, and then ask you whether there is a path to repeat the maximum number of letters on the path of how many times, the example has a path of the vertex sequence is Abcaca then the answer is 3, because a appears three times, if the answer is infinitely large then output-1Analysis:It is not difficult to associate with a topic of dynamic programming type
"RMQ" range minimum/maximum Query range max problem"St Algorithm"An effective algorithm for solving RMQ problems pretreatment pre-treatment to construct D, preprocessing time complexity O (NLOGN)Using the idea of dynamic programming D (I, j) indicates that the minimum value of the range I ~ i + 2j-1 has a state transition equation D (i, j) = min {d (i, j-1), D (i + 2j-1, j-1)} Set the original data stored in the array a[], the initial stateD (i, 0) = a[i] Querying for the maximum time comp
Key to solving problems:
Understand structural features, abstract state, and write state transition equations.
Topic Index
1. Triangle find a minimum path from top to bottom
Analysis
The state is F (i; j), indicating the minimum and the path from the position (i; j), then the state transition equation is
F (i,j) =min{f (I+1,j), F (i+1,j+1)}+ (I,J)
2. Maximum sub-arrays and
The state is F[j], which represents the largest continuous subsequence ending with s[j], and the state transition equation
represents the sum of the maximum power values of Sample Input
4 51 1 1 11 2 11 11 Sample Output
6 Data Limit
For 40% of data, nFor 100% of the data, n
The DP on the skill tree is an easy-to-think DP problem, because this tree-like structure of DP everyone is very familiar with, get this problem is easy to think of as a tree gauge or from the top down, from th
modulo 1000000007.Sample Input5 2 3 2Sample Output6 HintSample input means you can choose 1 and 4,1 and 5,2 and 5 in the same day. And you can make the machines in the same group or the different group. Got 6 schemes.1 and 4 in same group,1 and 4 in different groups.1 and 5 in same group,1 and 5 in different groups.2 and 5 in same group,2 and 5 in different groups. We assume 1 in a group and 4 in B group are the same as 1 in B group and 4 in a group.Test instructions, now there are 1 t
HDU4960Another OCD Patient (interval dp, block before DP)Another OCD PatientTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission (s): 716 Accepted Submission (s): 270Problem DescriptionXiaoji is an OCD (obsessive-compulsive disorder) patient. this morning, his children played with plasticene. they broke the plasticene into N pieces, and put them in a line. each
After listening to the great idea of zwk, I immediately went to 1A.
The idea is as follows:
When calculating the minimum GPA, first, each subject is allocated to 69 points (if not enough, GPA 2 is output directly), and then the for loop is used to reduce the remain point. The maximum value of each subject is increased to 100.
When calculating the maximum GPa, each subject is allocated to 60 points, and then the for loop is used to reduce the remain point. The upper limit of each subject is incre
Charm Bracelet
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 47440
Accepted: 20178
DescriptionBessie have gone to the mall ' s jewelry store and spies a charm bracelet. Of course, she ' d like-to-fill it with the best charms possible from the N (1≤ n ≤3,402) available Char Ms. Each charm I in the supplied list has a weight wi (1≤ wi ≤400), a ' desirability ' factor C5>di (1≤ Di ≤100), and can be used at the most once. B
Test instructions: Dairy cows, farmers have m time can be milking, in the working hours F t milk production is m, after each milking, the cows need to rest R. Q: How to make the most milk production?Idea: Interval DP dp[i] denotes the first time period
To the farmer work the end time by small to large sort
Inter[k].e+r>inter[i].b for the first time period if the previous record is not in confli
representing the maximum power value and Sample Input
4 51 1 1 11 2 11 11 Sample Output
6 Data Limit
For 40% of the data, nFor 100% of the data, n
The DP on the skill tree is a DP problem that is not easy to think about, because this kind of tree structure DP Everybody is very familiar with, gets this question very easy to want to become the tree regulation or
Talking about one-dimension array of DP algorithm (I) solving the 01 knapsack problem and the dp dimension
Introduction to DP algorithm (I)
-- How to use a one-dimensional array to solve the 01 knapsack problem
Dynamic Programming (also known as Dynamic planning) is one of the most classic algorithms. This document introduces the familiar number tower problem an
Test instructionsGiven n deep1, constructs an n node of the tree with a weight, and the maximum depth is deep, each node can have a maximum of 2 sons2, the value of each node is 2^0, 2^1 2^ (n-1) Any two node values cannot be the same3, for a node, if he has left and right son, then the left sub-tree and the R Train of thought: Set dp[i] [j] for node number I, depth not exceeding j of the tree to meet the conditions. First consider the invlid situatio
the length of the longest ski trail.Sample input15 41 3 32 3 43 4 13 5 2Sample output6Test instructions: In this winter vacation, Bob has plans to ski in the mountain resort. This ski resort has m different ski runs and n different signs located at those corner points. The path from the first mark to the T flag has a length of L. Each path must follow the principle of lowering the height, and the starting point must be strictly above the end point. Now, you should help Bob find the longest ski
1. Problem of Stone mergingDP[I][J] represents the minimum cost required to merge the interval I to J.First, the minimum cost of the inter-cell, and then transfer to a large interval.Transfer equation: Dp[i][j]=min (dp[i][j],dp[i][k]+dp[k+1][j])Initial state: Dp[i][i]=0Templ
Analysis: Dp[i][j] represents the minimum squared sum of J logarithm in the first I element
Dp[i][j] = min (Dp[i-1][j], dp[i-2][j-1] + (Weight[i]-weight[i-1]) * (Weight[i]-weight[i-1]));
Code
#include #include
#define MIN (a) > (b)? (b): (a))#define Maxallow 2147483648const int num = 2001;
int CMP (const void* A, cons
, output an integer that represents the editing distance of two strings.Each answer takes up one line.
Sample Input2David
Vivian
Abc
Aabbcc
Sample Output43
"Thought Analysis" dp[i][j] represents the number of times a 0-i character in the first string becomes 0-j in the second string.Let's analyze it in several parts below.1.i=0 when the dp[0][j]=j;2.j=0 when the dp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.