日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

cesium广告牌_公路广告牌

發布時間:2025/3/11 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cesium广告牌_公路广告牌 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

cesium廣告牌

Description:

描述:

This is a standard dynamic programing problem of finding maximum profits with some constraints. This can be featured in any interview coding rounds.

這是在某些約束條件下找到最大利潤的標準動態編程問題。 這可以在任何采訪編碼回合中體現。

Problem statement:

問題陳述:

Consider a highway of M miles. The task is to place billboards on the highway such that revenue is maximized. The possible sites for billboards are given by number x1 < x2 < ... < x(n-1) < xn specifying positions in miles measured from one end of the road. If we place a billboard at position xi, we receive a revenue of ri > 0. The constraint is that no two billboards can be placed within t miles or less than it.

考慮一條M英里的高速公路。 任務是在高速公路上放置廣告牌,以使收入最大化。 廣告牌的可能位置由數字x 1 <x 2 <... <x (n-1) <x n給出,指定從道路的一端算起的英里位置。 如果將廣告牌放置在x i位置,我們的收入r i > 0 。 約束條件是在t英里以內或小于t英里內不能放置兩個廣告牌。

Input:M=15, n=5x[n]= {6,8,12,14,15}revenue[n] = {3,6,5,3,5}t = 5Output:11

Explanation with example

舉例說明

So, we have to maximize the revenue by placing the billboards where the gap between any two billboard is t.

因此,我們必須通過將廣告牌放置在任意兩個廣告牌之間的距離為t的位置來最大化收入。

Here,

這里,

The corresponding distances of the billboards with respect to the origin are,

廣告牌相對于原點的相應距離為

x[5]= {6,8,12,14,15}

We can augment the origin, so the augmented array becomes: (no need to augment if origin revenue exists)

我們可以擴充原點,因此擴充后的數組將變為:(如果存在原點收入,則無需擴充)

x[6]= {0,6,8,12,14,15}t=5

The graphical interpretation of the billboards is like following:

廣告牌的圖形解釋如下:



Figure 1: Billboards

圖1:廣告牌

The augmented revenue array:

擴充收益陣列:

revenue[6] = {0,3,6,5,3,5}

Now, the brute force approach can be to check all the possible combination of billboards and updating the maximum revenue accumulated from each possible combinations.

現在,暴力破解方法可以是檢查廣告牌的所有可能組合,并更新每個可能組合所累積的最大收益。

Few of such possible combinations can be:

這樣的可能組合很少是:

So, maximum revenue that can be collected is 11.

因此,可以收取的最大收入為11 。

For any billboard bi we have three choices

對于任何廣告牌b 都有三種選擇

  • Don't pick bi

    不要選擇

  • Start from bi

    開始

  • Pick bi and other billboards accordingly

    相應地選擇b i和其他廣告牌

  • Say,

    說,

    M(i)=maximum revenue upto first i billboards

    So,

    所以,

    M(0)=0if bi is not picked, M(i)=M(i-1)if billboard placement starts from bi M(i)=r[i]If we place bi then need to pace bj where d[i]>d[j]-t such that revenue maximizesSo,

    Problem Solution approach

    問題解決方法

    We convert the above recursion to dynamic programing as there will many overlapping sub problems solving the recursion. (Try to generate the recursion tree yourself)

    我們將上述遞歸轉換為動態編程,因為將會有許多重疊的子問題解決遞歸。 (嘗試自己生成遞歸樹)

    1) Construct DP[n] for n billboards// considering billboard placing starts from it2) Fill the array with base value which is r[i] 3) for i=1 to n-1// recursion case 1 and 2// either not picking ith billboard or starting // from ith billboard which ever is maximumdp[i] = max(dp[i-1],dp[i]);// recursion case 3// picking ith billboardfor j=0 to i-1if(a[j]< a[i]-k)//feasible placingdp[i]= max(dp[i],dp[j]+r[i]);end forend forResult is dp[n-1]

    C++ implementation:

    C ++實現:

    #include <bits/stdc++.h> using namespace std;int max(int x, int y) {return (x > y) ? x : y; }int billboard(vector<int> a, vector<int> r, int n, int k) {int dp[n];for (int i = 0; i < n; i++)dp[i] = r[i];//base valuedp[0] = r[0];for (int i = 1; i < n; i++) {//first two recursion caseint mxn = max(dp[i - 1], dp[i]);//picking ith billboard, third recursion casefor (int j = 0; j < i; j++) {if (a[j] < a[i] - k)mxn = max(mxn, dp[j] + r[i]);}dp[i] = mxn;}return dp[n - 1]; }int main() {int n, k, item, m;cout << "Enter highway length:\n";cin >> m;cout << "Enter number of billboards\n";cin >> n;cout << "Enter minimum distance between any two billboards\n";cin >> k;vector<int> a;vector<int> r;cout << "Enter billboard distances one by one from origin\n";for (int i = 0; i < n; i++) {cin >> item;a.push_back(item);}cout << "Enter revenues for the respective billboards\n";for (int i = 0; i < n; i++) {cin >> item;r.push_back(item);}if (a[0] == 0) {a.insert(a.begin(), 0);r.insert(r.begin(), 0);n = n + 1;}cout << "Maximum revenue that can be collected is: " << billboard(a, r, n, k) << endl;return 0; }

    Output

    輸出量

    RUN 1: Enter highway length: 20 Enter number of billboards 5 Enter minimum distance between any two billboards 5 Enter billboard distances one by one from origin 3 7 12 13 14 Enter revenues for the respective billboards 15 10 1 6 2 Maximum revenue that can be collected is: 21RUN 2: Enter highway length: 15 Enter number of billboards 5 Enter minimum distance between any two billboards 5 Enter billboard distances one by one from origin 6 8 12 14 15 Enter revenues for the respective billboards 3 6 5 3 5 Maximum revenue that can be collected is: 11

    翻譯自: https://www.includehelp.com/icp/highway-billboard.aspx

    cesium廣告牌

    總結

    以上是生活随笔為你收集整理的cesium广告牌_公路广告牌的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 免费福利在线观看 | 亚洲视频色图 | 美梦视频大全在线观看高清 | 日批在线观看 | 少妇与公做了夜伦理 | 夜久久久| 久久久国 | 在线观看黄色免费视频 | 男人天堂tv | 国产美女在线精品 | 环太平洋3:泰坦崛起 | 日韩午夜电影网 | 伊人久久艹 | 日噜 | 国产成人精品在线观看 | 国产123 | 色综合免费视频 | 一区精品视频在线观看 | 日本91av| 欧美一区二区三区四区五区 | 日韩在线综合 | 97成人资源站 | 中文字幕在线观看高清 | 国产一级片免费在线观看 | 亚洲免费av网 | 日本午夜精华 | 最近中文字幕在线中文视频 | 国产91精品一区二区绿帽 | 在线观看的毛片 | 午夜精品在线免费观看 | 久久99精品久久久久子伦 | www日本xxx | 超碰免费在线 | 亚洲视频在线观看一区 | 免费日本黄色片 | 中文在线不卡视频 | 五月婷婷免费视频 | 国产91熟女高潮一区二区 | 女人私密又肥又大 | 国产一区二区波多野结衣 | 美丽的小蜜桃2:美丽人生 | 欧美精彩视频 | 97欧美视频 | 欧美一区二区三区啪啪 | 性生活av| 国产成人啪精品午夜在线观看 | 国产一区二区网站 | 亚洲videos | 草民午夜理伦三级 | 麻豆成人入口 | 少妇被黑人到高潮喷出白浆 | 精品无码久久久久国产 | 老司机黄色片 | 色之久久综合 | 香蕉小视频| 国产一区二区精彩视频 | 樱井莉亚av | 精品国产一区二 | 快播av在线 | 国产主播专区 | 欧美日韩精品在线观看 | 韩国一级淫一片免费放 | 久久精品视频在线免费观看 | 97超碰站| 国产av无码专区亚洲av毛网站 | 椎名空在线观看 | 波多野结衣办公室双飞 | 蜜臀av在线免费观看 | 麻豆国产一区二区三区四区 | 在线观看第一页 | 古代黄色一级片 | a级无遮挡超级高清-在线观看 | 亚洲精选一区二区 | 精品人妻一区二区三区蜜桃 | 日韩欧美高清视频 | 日本一区二区网站 | 精品视频在线观看一区 | 丰满岳乱妇在线观看中字无码 | 日韩成人av免费在线观看 | 亚洲人 女学生 打屁股 得到 | 亚洲视频一二区 | 97精品人妻一区二区三区在线 | 天天色天天射综合网 | 午夜视频在线免费看 | 草莓视频一区二区三区 | 黄色三级网 | 免费无码国产精品 | 亚洲人 女学生 打屁股 得到 | 久久精品女人毛片国产 | 日韩色图在线观看 | 久久久久国产一区二区三区潘金莲 | 日韩欧美在线看 | 777理伦三级做爰 | 色欧美日韩 | 成人视频在线观看 | 欧美一级少妇 | 色图自拍| 四虎影院一区 | 国产在线观看你懂的 |