zoukankan      html  css  js  c++  java
  • 3.18~Billboards

    转载注明出处  http://www.cnblogs.com/ligun123/archive/2013/03/19/2969477.html

    题目来源:https://www.hackerrank.com/challenges/billboards

    Billboards

    ADZEN is a very popular advertising firm in your city. In every road you can see their advertising billboards. Recently they are facing a serious challenge , MG Road the most used and beautiful road in your city has been almost filled by the billboards and this is having a negative effect on the natural view.

    On people’s demand ADZEN has decided to remove some of the billboards in such a way that there are no more than K billboards standing together in any part of the road.

    You may assume the MG Road to be a straight line with N billboards.Initially there is no gap between any two adjecent billboards.

    ADZEN’s primary income comes from these billboards so the billboard removing process has to be done in such a way that the billboards remaining at end should give maximum possible profit among all possible final configurations.Total profit of a configuration is the sum of the profit values of all billboards present in that configuration.

    Given N,K and the profit value of each of the N billboards, output the maximum profit that can be obtained from the remaining billboards under the conditions given.

    Input description 

    Ist line contain two space seperated integers N and K. Then follow N lines describing the profit value of each billboard i.e ith line contains the profit value of ith billboard.

    Sample Input
    6 2 
    1
    2
    3
    1
    6
    10 

    Sample Output
    21

    Explanation

    In given input there are 6 billboards and after the process no more than 2 should be together.
    So remove 1st and 4th billboards giving a configuration _ 2 3 _ 6 10 having a profit of 21. No other configuration has a profit more than 21.So the answer is 21.

    Constraints
    1 <= N <= 1,00,000(10^5)
    1 <= K <= N
    0 <= profit value of any billboard <= 2,000,000,000(2*10^9)

    待续~~参考背包问题求解

  • 相关阅读:
    R语言初涉
    Android源码大全
    Centos关闭防火墙
    Java开发常用下载的网址
    linux下解压命令大全
    Android常见布局问题
    配置Nutch模拟浏览器以绕过反爬虫限制
    Nutch的发展历程
    用三层交换机当路由器——最复杂的网络拓扑结构
    Ant 简易教程
  • 原文地址:https://www.cnblogs.com/ligun123/p/2969477.html
Copyright © 2011-2022 走看看