题目链接http://codeforces.com/contest/762/problem/D

多多分析状态;这个很明了

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #pragma comment(linker, "/STACK:102400000,102400000")
  4. #define ls i<<1
  5. #define rs ls | 1
  6. #define mid ((ll+rr)>>1)
  7. #define pii pair<LL,int>
  8. #define MP make_pair
  9. typedef long long LL;
  10. const long long INF = 1e18;
  11. const double Pi = acos(-1.0);
  12. const int N = 1e6+, M = 2e6+, mod = 1e9+, inf = 2e9;
  13.  
  14. void update(LL &x,const LL &y) {
  15. if(x < y) x = y;
  16. }
  17. LL a[][N],dp[][N];
  18. int n;
  19. int main() {
  20. scanf("%d",&n);
  21. for(int i = ; i < ; ++i)
  22. for(int j = ; j <= n; ++j) scanf("%I64d",&a[i][j]);
  23. for(int i = ; i < ; ++i)
  24. for(int j = ; j <= n; ++j) dp[i][j] = -INF;
  25. dp[][] = ;
  26. for(int i = ; i <= n; ++i) {
  27. update(dp[][i],dp[][i-]+a[][i]);
  28. update(dp[][i],dp[][i-]+a[][i]+a[][i]);
  29. update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
  30. update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
  31.  
  32. update(dp[][i],dp[][i-]+a[][i]);
  33. update(dp[][i],dp[][i-]+a[][i]+a[][i]);
  34. update(dp[][i],dp[][i-]+a[][i]+a[][i]);
  35.  
  36. update(dp[][i],dp[][i-]+a[][i]);
  37. update(dp[][i],dp[][i-]+a[][i]+a[][i]);
  38. update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
  39. update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
  40.  
  41. update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
  42. update(dp[][i],dp[][i-]+a[][i]+a[][i]+a[][i]);
  43. }
  44. printf("%I64d\n",dp[][n]);
  45. return ;
  46. }

Educational Codeforces Round 17 D. Maximum path DP的更多相关文章

  1. Educational Codeforces Round 17

    Educational Codeforces Round 17 A. k-th divisor 水题,把所有因子找出来排序然后找第\(k\)大 view code //#pragma GCC opti ...

  2. Educational Codeforces Round 9 D. Longest Subsequence dp

    D. Longest Subsequence 题目连接: http://www.codeforces.com/contest/632/problem/D Description You are giv ...

  3. 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 ...

  4. Educational Codeforces Round 61 F 思维 + 区间dp

    https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...

  5. Educational Codeforces Round 51 D. Bicolorings(dp)

    https://codeforces.com/contest/1051/problem/D 题意 一个2*n的矩阵,你可以用黑白格子去填充他,求联通块数目等于k的方案数,答案%998244353. 思 ...

  6. 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 ...

  7. Educational Codeforces Round 17 颓废记

    又被虐了... (记一次惨痛的Codeforces) 好不容易登上去了Codeforces,22:35准时开打 第一题,一看:这不SB题嘛?直接枚举因数上啊.9min才过掉了pretest 第二题.. ...

  8. Educational Codeforces Round 32 E. Maximum Subsequence

    题目链接 题意:给你两个数n,m,和一个大小为n的数组. 让你在数组找一些数使得这些数的和模m最大. 解法:考虑 dfs但是,数据范围不允许纯暴力,那考虑一下折半搜索,一个从头开始往中间搜,一个从后往 ...

  9. 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 ...

随机推荐

  1. js事件 (包含call()方法使用特点)

    1.焦点事件 获取焦点事件onfocus\失去焦点事件onblur 例: oText.onfocus=function(){} 焦点:使浏览器能够区分用户输入的对象,当一个元素有焦点的时候,那么它就可 ...

  2. php S3

    转载自:http://www.cnblogs.com/wangxusummer/p/6398772.html <?php /* * To change this license header, ...

  3. python之 集合 学习笔记

    """ 集合内的元素是无序的,集合内的元素必须是可哈希的集合内元素的唯一的,不存在重复列表和字典不能存在集合里面,因为列表字典可变 可哈希集合也是不可哈希的 unhash ...

  4. 大数据学习——hive的sql练习

    1新建一个数据库 create database db3; 2创建一个外部表 --外部表建表语句示例: create external table student_ext(Sno int,Sname ...

  5. 一个监控oracle数据库某个字段值变化并发送邮件报警的脚本

    talk is cheap,here is the code: #!/bin/sh export ORACLE_HOME=/u01/app/oracle/product//client_1/ expo ...

  6. python021 Python3 错误和异常

    Python3 错误和异常 作为Python初学者,在刚学习Python编程时,经常会看到一些报错信息,在前面我们没有提及,这章节我们会专门介绍. Python有两种错误很容易辨认:语法错误和异常. ...

  7. hihoCoder#1133 二分·二分查找之k小数

    原题地址 经典问题了,O(n)时间内找第k大的数 代码: #include <iostream> using namespace std; int N, K; int *a; int se ...

  8. C 题 KMP中next[]问题

    题目大意: 找到能够进行字符串匹配的前缀 这题只要一直求next,直到next为0停止,记得答案是总长减去next的长度 #include <iostream> #include < ...

  9. 2014 蓝桥杯 预赛 c/c++ 本科B组 第九题:地宫取宝(12') [ dp ]

      历届试题 地宫取宝   时间限制:1.0s   内存限制:256.0MB     锦囊1   锦囊2   锦囊3   问题描述 X 国王有一个地宫宝库.是 n x m 个格子的矩阵.每个格子放一件 ...

  10. PHP中的魔术方法【转载】

    __construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup, _ ...