摘要:此题我觉得非常的亢爹,用while(cin>>n)输入肯定wa,原因不详,所以此题只能用while(scanf("%d",&n)!=EOF),作为输入语句。ac代码:View Code #include<iostream>using namespace std;const int M=38000;int dp[M];int main(){ /*freopen("in.txt","r",stdin); freopen("out1.txt","w",stdout);*
阅读全文
摘要:题意:第1列单调递增,第2列单调递减,满足这两个要求最长的子序列。ac代码:View Code #include<iostream>#include<stack>#include<algorithm>using namespace std;struct node{ int num;//记录输入的顺序 int weight; int rate; const bool operator<(struct node &d)const{ //重载小于号,作用:结构体中的元素按weight的升序排列 return weight<d.weight; }
阅读全文
摘要:题意:输出最大子序列和。解法:DPac代码:#include<iostream>using namespace std;#define mem(x,y) memset(x,y,sizeof(x));const int M=100099;int a[M];//存储输入的数int sum[M];//sum[i]代表第i个为结尾的最大和int front[M];//front[i]代表以i为结尾的最大子串和的起始位置int main(){ int t; cin>>t; int l=1; while(t--) { mem(sum,0);mem(front,0...
阅读全文