poj 2593&&poj2479(最大两子段和)】的更多相关文章

Max Sequence Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16850   Accepted: 7054 Description Give you N integers a1, a2 ... aN (|ai| <=1000, 1 <= i <= N). You should output S. Input The input will consist of several test cases. Fo…
就是按着DP的思路来做的,结果还是想不到.T_T,行了,别玻璃心了,继续. 这道题目是求在一列数里,由两部分子段和组成的最大和.即对于连续整数组成的串 S1.S2,使 S1 + S2 的和最大. 题目与求最大子段和有相似之处,可以说是最大子段和的变形. 最大子段和: 在一列数里,对于连续整数组成的串S,使 S 的值最大. 最大子段和的动态规划方程, dp[i] = max(dp[i-1] + arr[i], arr[i]); 意义:当遍历到当前第 i 个数时,比较 {前一状态dp[i-1] 加上…
题目链接:http://poj.org/problem?id=2593 思路分析:该问题为求给定由N个整数组成的序列,要求确定序列A的2个不相交子段,使这m个子段的最大连续子段和的和最大. 该问题与poj 2479相同,解法也一样: 代码如下: #include <cstdio> #include <iostream> using namespace std; + ; int arr[MAX_N], dp_s[MAX_N], dp_r[MAX_N]; int arr_num; in…
d(A) = max{sum(a[s1]..a[t1]) + sum(a[s2]..a[t2]) | 1<=s1<=t1<s2<=t2<=n} 即求两个子序列和的和的最大值. 为单个区间子序列和的最大值的变形. 左边的从左向右扫描,而右边的从右向左扫描即可. #include<cstdio> #include<algorithm> using namespace std; const int MAXN=50000+10; int left[MAXN],…
Common Substrings Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 11469   Accepted: 3796 Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B and one integer K, we define S,…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 31904   Accepted: 12876 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days…
题意 ​ 题目主要说的是,有两只青蛙,在两个石头上,他们之间也有一些石头,一只青蛙要想到达另一只青蛙所在地方,必须跳在石头上.题目中给出了两只青蛙的初始位置,以及剩余石头的位置,问一只青蛙到达另一只青蛙所在地的所有路径中的"the frog distance"中的最小值. ​ 解释一下"the frog distance": 题目中给出了一段解释"The frog distance (humans also call it minimax distance…
Max Sequence Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16329   Accepted: 6848 Description Give you N integers a1, a2 ... aN (|ai| <=1000, 1 <= i <= N). You should output S.  Input The input will consist of several test cases. F…
Max Sequence Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17678   Accepted: 7401 Description Give you N integers a1, a2 ... aN (|ai| <=1000, 1 <= i <= N).  You should output S.  Input The input will consist of several test cases.…
题 利用叉积解方程 #include <cstdio> #define MAX 1<<31 #define dd double int xmult(dd x1,dd y1,dd x2,dd y2,dd x,dd y){ return (x1-x)*(y2-y)-(x2-x)*(y1-y); } int main(){ int n; dd x1,y1,x2,y2,x3,y3,x4,y4; scanf("%d",&n); puts("INTERSE…