• 一道花了我1个小时的初级DP


    这是这段时间最后一次更新DP了,,这东西太难学了,换图论模板去,,以后再学这东西

    就贴题目了:http://acm.hdu.edu.cn/showproblem.php?pid=1024

    解:https://www.cnblogs.com/dongsheng/archive/2013/05/28/3104629.html(好像代码还没过,超时了)

          http://blog.sina.com.cn/s/blog_677a3eb30100jxqa.html

    题目:

    Max Sum Plus Plus

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 12589    Accepted Submission(s): 4146


    Problem Description
    Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem.

    Given a consecutive number sequence S1, S2, S3, S4 ... Sx, ... Sn (1 ≤ x ≤ n ≤ 1,000,000, -32768 ≤ Sx ≤ 32767). We define a function sum(i, j) = Si + ... + Sj (1 ≤ i ≤ j ≤ n).

    Now given an integer m (m > 0), your task is to find m pairs of i and j which make sum(i1, j1) + sum(i2, j2) + sum(i3, j3) + ... + sum(im, jm) maximal (ix ≤ iy ≤ jx or ix ≤ jy ≤ jx is not allowed).

    But I`m lazy, I don't want to write a special-judge module, so you don't have to output m pairs of i and j, just output the maximal summation of sum(ix, jx)(1 ≤ x ≤ m) instead. ^_^
     
    Input
    Each test case will begin with two integers m and n, followed by n integers S1, S2, S3 ... Sn.
    Process to the end of file.
     
    Output
    Output the maximal summation described above in one line.
     
    Sample Input
    1 3 1 2 3
    2 6 -1 4 -2 3 -2 3
     
    Sample Output
    6
    8
    Hint
    Huge input, scanf and dynamic programming is recommended.
     
  • 相关阅读:
    java类型转换
    JVM内存各个区域分工简单介绍
    用数组实现栈
    一些关于Spring的随笔
    设计模式学习笔记(三)之静(动)态代理模式、适配器模式
    浅谈经典排序算法
    PetStore项目总结
    设计模式学习笔记(二)之观察者模式、装饰者模式
    Spring的校验(Validator)
    设计模式学习笔记(一)之工厂模式、单例模式
  • 原文地址:https://www.cnblogs.com/huangzzz/p/7867902.html
Copyright © 2020-2023  润新知