P2858 [USACO06FEB]奶牛零食Treats for the Cows
区间dp,级像矩阵取数,
f[i][i+l]=max(f[i+1][i+l]+a[i]*(m-l),f[i][i+l-1]+a[i+l]*(m-l));

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#define inf 2147483647
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()
//by war
//2017.10.19
using namespace std;
int n,m;
int a[];
int f[][];
int Max;
int ans;
void in(int &x)
{
int y=;
char c=g();x=;
while(c<''||c>'')
{
if(c=='-')
y=-;
c=g();
}
while(c<=''&&c>='')x=x*+c-'',c=g();
x*=y;
}
void o(int x)
{
if(x<)
{
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main()
{
in(m);
For(jj,,m)
in(a[jj]);
For(i,,m)
f[i][i]=m*a[i];
For(l,,m-)
For(i,,m-l)
f[i][i+l]=max(f[i+][i+l]+a[i]*(m-l),f[i][i+l-]+a[i+l]*(m-l));
o(f[][m]);
return ;
}

最新文章

  1. bug描述技巧
  2. Play Framework 完整实现一个APP(十二)
  3. FPGA与simulink联合实时环路系列——实验一 测试
  4. centos7 开启防火墙端口 firewalld
  5. FL2440驱动添加(4)LED 驱动添加
  6. [ASP.NET MVC] ASP.NET Identity学习笔记 - 原始码下载、ID型别差异
  7. Jdev Run Page 没有反应
  8. gotoTop返回顶部 JS
  9. 代码实现native2assci
  10. jsoup 对网页中图片解析
  11. hdu 5012 Dice
  12. 【jQuery】使用JQ要准备的主要淡入淡出效果
  13. 在使用cognos时遇到的问题记录帖
  14. b树和hash树的应用场景
  15. 【mongo】查询超时处理
  16. Spark配置参数详解
  17. django中forms和modelform组件的区别
  18. RuntimeError: Model class apps.users.models.User doesn&#39;t declare an explicit app_label and isn&#39;t in an application in INSTALLED_APPS.
  19. weblogic优化(内存、线程数和启动速度)
  20. Nginx详解十三:Nginx场景实践篇之防盗链

热门文章

  1. Android Service总结05 之IntentService
  2. bzoj 1824: [JSOI2010]下棋问题
  3. Json对象与Json字符串
  4. javaWeb接口开发
  5. div 内table 居中实现代码
  6. Python数据分析初始(一)
  7. HTTP header location 重定向 URL
  8. Spark记录-Scala类和对象
  9. HTML的文档类型:&lt;!DOCTYPE &gt;
  10. javascript的this分别代表什么