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 ...
随机推荐
- js事件 (包含call()方法使用特点)
1.焦点事件 获取焦点事件onfocus\失去焦点事件onblur 例: oText.onfocus=function(){} 焦点:使浏览器能够区分用户输入的对象,当一个元素有焦点的时候,那么它就可 ...
- php S3
转载自:http://www.cnblogs.com/wangxusummer/p/6398772.html <?php /* * To change this license header, ...
- python之 集合 学习笔记
""" 集合内的元素是无序的,集合内的元素必须是可哈希的集合内元素的唯一的,不存在重复列表和字典不能存在集合里面,因为列表字典可变 可哈希集合也是不可哈希的 unhash ...
- 大数据学习——hive的sql练习
1新建一个数据库 create database db3; 2创建一个外部表 --外部表建表语句示例: create external table student_ext(Sno int,Sname ...
- 一个监控oracle数据库某个字段值变化并发送邮件报警的脚本
talk is cheap,here is the code: #!/bin/sh export ORACLE_HOME=/u01/app/oracle/product//client_1/ expo ...
- python021 Python3 错误和异常
Python3 错误和异常 作为Python初学者,在刚学习Python编程时,经常会看到一些报错信息,在前面我们没有提及,这章节我们会专门介绍. Python有两种错误很容易辨认:语法错误和异常. ...
- hihoCoder#1133 二分·二分查找之k小数
原题地址 经典问题了,O(n)时间内找第k大的数 代码: #include <iostream> using namespace std; int N, K; int *a; int se ...
- C 题 KMP中next[]问题
题目大意: 找到能够进行字符串匹配的前缀 这题只要一直求next,直到next为0停止,记得答案是总长减去next的长度 #include <iostream> #include < ...
- 2014 蓝桥杯 预赛 c/c++ 本科B组 第九题:地宫取宝(12') [ dp ]
历届试题 地宫取宝 时间限制:1.0s 内存限制:256.0MB 锦囊1 锦囊2 锦囊3 问题描述 X 国王有一个地宫宝库.是 n x m 个格子的矩阵.每个格子放一件 ...
- PHP中的魔术方法【转载】
__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup, _ ...