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 ...
随机推荐
- 《算法导论》 — Chapter 10 基本数据结构
序 在本章中,要讨论如何通过使用了指针的简单数据结构表示动态集合.有很多的复杂的数据结构可以用指针来构造,本章介绍几种基本数据结构,包括栈.队列.链表,以及有根树. GitHub 第十章 程序实现代码 ...
- c++值传递和引用及指针传递区别
以下程序各有何问题? ***************************************************************************************** ...
- 【转】反向AJAX
原文链接:http://blog.csdn.net/lccone/article/details/7743886 反向Ajax的基本概念是客户端不必从服务器获取信息,服务器会把相关信息直接推送到客户端 ...
- POJ-1861,Network,最小生成树水题,,注意题面输出有问题,不必理会~~
Network Time Limit: 1000MS Memory Limit: 30000K Special Judge http://poj.org/problem?id=1 ...
- POJ3246-Balanced Lineup,好经典的题,做法和HDU-I hate it 一样~~
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Case Time Limit: 2000MS Description For ...
- 【记录】新建Cordova项目出现ios-deploy找不到的问题
按老流程 Cordova create helloApp Cordova platform add ios 之前一般这种操作之后就能有执行的iOS目录了,像这样 然后 Cordova build ...
- BZOJ1740: [Usaco2005 mar]Yogurt factory 奶酪工厂
n<=10000天每天Ci块生产一东西,S块保存一天,每天要交Yi件东西,求最少花多少钱. 这个我都不知道归哪类了.. #include<stdio.h> #include<s ...
- FusionCharts for Flex 如何更改图表数据
FusionCharts allows to change chart data and re-render the chart, after it has loaded on the user’s ...
- 洛谷——P1551 亲戚
题目背景 若某个家族人员过于庞大,要判断两个是否是亲戚,确实还很不容易,现在给出某个亲戚关系图,求任意给出的两个人是否具有亲戚关系. 题目描述 规定:x和y是亲戚,y和z是亲戚,那么x和z也是亲戚.如 ...
- 关于用String Calender类 计算闰年的Demo
package cn.zmh.zuoye; import java.util.Calendar; public class StringRun { public static void main(St ...