zoukankan      html  css  js  c++  java
  • 一道花了我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.
     
  • 相关阅读:
    Discuz的sc 和tc版本有什么区别
    使用Word2010发布博客到博客园
    如何快速产生流量,流量精灵使用方法
    XP系统如何把桌面图标变大
    打印机后台程序没有运行怎么办
    CF无法全屏怎么办
    XP如何找到网上邻居
    P2P终结者和反P2P终结者如何使用
    PortableApps的使用方法
    JavaScript,JS如何控制input输入字符限制
  • 原文地址:https://www.cnblogs.com/huangzzz/p/7867902.html
Copyright © 2011-2022 走看看