DP 复习。

参考 redbag 博客 提供的题表。

P2858 [USACO06FEB] Treats for the Cows

区间 DP。

转换思路,题面从外往里递推,我们采用从里往外递推,权值逐级递减的反向实现方式。

选择区间左端点或右端点更新答案。

int n, a[2003], f[2003][2003];

int main() {
scanf("%d", &n);
for (int i=1; i<=n; ++i) scanf("%d", &a[i]), f[i][i]=a[i]*n;
for (int k=1; k<n; ++k) for (int i=1; i+k<=n; ++i)
f[i][i+k]=max(f[i+1][i+k] + a[i]*(n-k), f[i][i+k-1] + a[i+k]*(n-k));
printf("%d\n", f[1][n]);
return 0;
}

P2867 [USACO06NOV] Big Square

多重背包。

30 August的更多相关文章

  1. centos各版本信息

    CentOS version Architectures RHEL base Kernel CentOS release date RHEL release date Delay (days) 2.1 ...

  2. C#DateTime的用法

    本文较详细地介绍了C#的DateTime对象的使用方法.DateTime.Now.ToShortTimeString() DateTime dt = DateTime.Now; dt.ToString ...

  3. Enhancing the Scalability of Memcached

    原文地址: https://software.intel.com/en-us/articles/enhancing-the-scalability-of-memcached-0 1 Introduct ...

  4. CentOS和Redhat发行版linux内核版本的对应关系

    由于Redhat和CentOS的发行版本现在众多,所以我们应该知道CentOS和Redhat及linux内核之间版本的对应关系对维护系统还是很有帮助的.对应的列表如下: Redhat 9.0————— ...

  5. Unofficial Microsoft SQL Server Driver for PHP (sqlsrv)非官方的PHP SQL Server 驱动

    原文 Unofficial Microsoft SQL Server Driver for PHP (sqlsrv) Here are unofficial modified builds of Mi ...

  6. [官网]Linux版本历史

    This is a list of links to every changelog. https://kernelnewbies.org/LinuxVersions 总结一下 2.6.x 存在了八年 ...

  7. CCF计算机网络会议日期

    SenSys: November 5-8 2017, Deadline: April 3, 2017 CoNEXT: December 12-15 2017, Deadline: June 12, 2 ...

  8. c# 根据当前时间获取,本周,本月,本季度,月初,月末,各个时间段(转但是都是使用过)

    DateTime dt = DateTime.Now;  //当前时间 DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") 24小时制 Dat ...

  9. [ZZ]Sign Up for the First-Ever Appium Roadshow on August 20th in New York City

    http://sauceio.com/index.php/2014/07/appium-roadshow-nyc/?utm_source=feedly&utm_reader=feedly&am ...

随机推荐

  1. django-xadmin常用内容记录

    自定义菜单名称: 1 修改app下的 apps.py文件 添加 class OperationConfig(AppConfig): name = 'operation' verbose_name = ...

  2. Trailing Zeroes (III) LightOJ - 1138 不找规律-理智推断-二分

    其实有几个尾零代表10的几次方但是10=2*510^n=2^n*5^n2增长的远比5快,所以只用考虑N!中有几个5就行了 代码看别人的: https://blog.csdn.net/qq_422797 ...

  3. github创建仓库,往github上上传自己的项目

    k第一步: 在github上创建仓库 第二步: 创建一个新的项目,填写项目名称,描述 创建完成之后,跳转到下面的页面,下面红框中的网址要记住,在后面上传代码的时候需要使用 这个地址必须要记住!!! 第 ...

  4. Html mate标签的常见功能

    一.常用的功能 1.禁止屏幕缩放 <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, us ...

  5. HDU 1880 题解(字符串哈希)

    题面: 魔咒词典 Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  6. 移动端1像素解决方法,根据媒体查询transform缩放

    .borderOnePx{ position: relative; } .borderOnePx::after { content: ''; height:1px; background:#000; ...

  7. 运维脚本-elasticsearch数据迁移python3脚本

    elasticsearch数据迁移python3脚本 #!/usr/bin/python3 #elsearch 数据迁移脚本 #迁移工具路径 import time,os #下面命令是用到了一个go语 ...

  8. SCUT - 31 - 清一色 - dfs

    https://scut.online/p/31 还是不知道为什么RE了.的确非常玄学. 重构之后就没问题了.果然写的越复杂,分的情况越乱就越容易找不到bug. #include<bits/st ...

  9. Elasticsearch7.X 入门学习第五课笔记---- - Mapping设定介绍

    原文:Elasticsearch7.X 入门学习第五课笔记---- - Mapping设定介绍 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本 ...

  10. SpringBoot中设置自定义拦截器

    SpringBoot中设置自动以拦截器需要写一个类继承HandlerInterceptorAdapter并重写preHandle方法 例子 public class AuthorityIntercep ...