zoukankan      html  css  js  c++  java
  • Maximum Absurdity DP + 数学

     Maximum Absurdity
    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
    Submit Status
    Appoint description: 

    Description

    Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.

    This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers ab(1 ≤ a ≤ b ≤ n - k + 1, b - a ≥ k) and sign all laws with numbers lying in the segments [aa + k - 1] and [bb + k - 1] (borders are included).

    As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.

    Input

    The first line contains two integers n and k (2 ≤ n ≤ 2·1050 < 2k ≤ n) — the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x1, x2, ..., xn — the absurdity of each law (1 ≤ xi ≤ 109).

    Output

    Print two integers ab — the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [aa + k - 1] and [bb + k - 1]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.

    Sample Input

    Input
    5 2
    3 6 1 1 6
    Output
    1 4
    Input
    6 2
    1 1 1 1 1 1
    Output
    1 3
    LL num[maxn];
    LL sum[maxn];
    LL dp[maxn];
    LL Max[maxn];//Max[i]代表i以后的最大值
    int id[maxn];//维护Max的起点
  • 相关阅读:
    IIS配置桌面上的文件报错,可能是含有中文字符
    GridView序号
    图片处理函数(自适应缩略图datatable中添加缩略图像)
    linqtoobject
    数据库存取图片二进制数据
    反射
    jquery
    加干扰字符
    Doc的窗口就创建一个,如果已经存在就激活那个窗口,不存在就建立Doc(转自CSDN)
    VC++中使用内存映射文件处理大文件(转)
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3415943.html
Copyright © 2011-2022 走看看