Educational Codeforces Round 17 D. Maximum path DP
题目链接:http://codeforces.com/contest/762/problem/D
多多分析状态;这个很明了
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<LL,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e18;
const double Pi = acos(-1.0);
const int N = 1e6+, M = 2e6+, mod = 1e9+, inf = 2e9; void update(LL &x,const LL &y) {
if(x < y) x = y;
}
LL a[][N],dp[][N];
int n;
int main() {
scanf("%d",&n);
for(int i = ; i < ; ++i)
for(int j = ; j <= n; ++j) scanf("%I64d",&a[i][j]);
for(int i = ; i < ; ++i)
for(int j = ; j <= n; ++j) dp[i][j] = -INF;
dp[][] = ;
for(int i = ; i <= n; ++i) {
update(dp[][i],dp[][i-]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]); update(dp[][i],dp[][i-]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]); update(dp[][i],dp[][i-]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]); update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
}
printf("%I64d\n",dp[][n]);
return ;
}
Educational Codeforces Round 17 D. Maximum path DP的更多相关文章
- Educational Codeforces Round 17
Educational Codeforces Round 17 A. k-th divisor 水题,把所有因子找出来排序然后找第\(k\)大 view code //#pragma GCC opti ...
- Educational Codeforces Round 9 D. Longest Subsequence dp
D. Longest Subsequence 题目连接: http://www.codeforces.com/contest/632/problem/D Description You are giv ...
- Codeforces Educational Codeforces Round 15 A. Maximum Increase
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 61 F 思维 + 区间dp
https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...
- Educational Codeforces Round 51 D. Bicolorings(dp)
https://codeforces.com/contest/1051/problem/D 题意 一个2*n的矩阵,你可以用黑白格子去填充他,求联通块数目等于k的方案数,答案%998244353. 思 ...
- Educational Codeforces Round 1 E. Chocolate Bar dp
题目链接:http://codeforces.com/contest/598/problem/E E. Chocolate Bar time limit per test 2 seconds memo ...
- Educational Codeforces Round 17 颓废记
又被虐了... (记一次惨痛的Codeforces) 好不容易登上去了Codeforces,22:35准时开打 第一题,一看:这不SB题嘛?直接枚举因数上啊.9min才过掉了pretest 第二题.. ...
- Educational Codeforces Round 32 E. Maximum Subsequence
题目链接 题意:给你两个数n,m,和一个大小为n的数组. 让你在数组找一些数使得这些数的和模m最大. 解法:考虑 dfs但是,数据范围不允许纯暴力,那考虑一下折半搜索,一个从头开始往中间搜,一个从后往 ...
- Educational Codeforces Round 17 C. Two strings 打表二分
C. Two strings time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
随机推荐
- ruby on rails全局布局,局部视图,局部布局
参考链接:http://guides.ruby-china.org/layouts_and_rendering.html#%E9%9D%99%E6%80%81%E8%B5%84%E6%BA%90%E6 ...
- Cisco路由器交换机基础配置
交换机配置 交换机基本状态: switch: # ROM状态, 路由器是rommon> hostname> # 用户模式 hostname# # 特权模式 hostname(config) ...
- Milk(sort+结构体)
Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to choose a bot ...
- 关于一个多个.cpp文件的项目中,函数出现未定义引用错误
编译的话,必须把全部的c文件都要编译的啊,只编译一个c算怎么个逻辑呢?编译实际上是2个过程,编译和链接.编译过程只检查所有的符号(变量,函数)有没有声明,即只需要h文件生命就够了.但是链接时候,需要找 ...
- 【ORACLE】查看死锁进程并结束死锁的脚本
--共享锁:Share:排他锁:Exclusive:行共享锁:Row-S:行排他锁:Row-X select V$SESSION.sid,v$session.SERIAL#,v$process.spi ...
- ubuntu安装远程桌面连接工具
1. 安装xrdp sudo apt-get -y install xrdp 2.安装vnc4server sudo apt-get install vnc4server 3.安装xubunt ...
- Sticky footer经典布局--绝对底部布局
原文转载于:https://cnodejs.org/topic/56ebdf2db705742136388f71 何为Sticky footer布局? 我们常见的网页布局方式一般分为header(页头 ...
- IDEA maven 无法加载已经安装的模块依赖包
今天打包一直报如下错误 Reactor Summary for freechain-op 1.0.1.OP: [INFO] [INFO] freechain-op .................. ...
- NOIP2014D2T2寻找道路(Spfa)
洛谷传送门 这道题可以把边都反着存一遍,从终点开始深搜,然后把到不了的点 和它们所指向的点都去掉. 最后在剩余的点里跑一遍spfa就可以了. ——代码 #include <cstdio> ...
- [luoguP3178] [HAOI2015]树上操作(dfs序 + 线段树 || 树链剖分)
传送门 树链剖分固然可以搞. 但还有另一种做法,可以看出,增加一个节点的权值会对以它为根的整棵子树都有影响,相当于给整棵子树增加一个值. 而给以某一节点 x 为根的子树增加一个权值也会影响当前子树,节 ...