<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

        CodeforcesRound#226(Div.2)ABearandRaspberry_html/css

        來源:懂視網(wǎng) 責(zé)編:小采 時間:2020-11-27 15:57:04
        文檔

        CodeforcesRound#226(Div.2)ABearandRaspberry_html/css

        CodeforcesRound#226(Div.2)ABearandRaspberry_html/css_WEB-ITnose:題目鏈接:Bear and Raspberry Bear and Raspberry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output
        推薦度:
        導(dǎo)讀CodeforcesRound#226(Div.2)ABearandRaspberry_html/css_WEB-ITnose:題目鏈接:Bear and Raspberry Bear and Raspberry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

        題目鏈接:Bear and Raspberry



        Bear and Raspberry

        time limit per test

        1 second

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1?≤?i?≤?n) day, the price for one barrel of honey is going to is xikilos of raspberry.

        Unfortunately, the bear has neither a honey barrel, nor the raspberry. At the same time, the bear's got a friend who is ready to lend him a barrel of honey for exactly one day for c kilograms of raspberry. That's why the bear came up with a smart plan. He wants to choose some day d (1?≤?d?

        The bear wants to execute his plan at most once and then hibernate. What maximum number of kilograms of raspberry can he earn? Note that if at some point of the plan the bear runs out of the raspberry, then he won't execute such a plan.

        Input

        The first line contains two space-separated integers, n and c (2?≤?n?≤?100,?0?≤?c?≤?100), ? the number of days and the number of kilos of raspberry that the bear should give for borrowing the barrel.

        The second line contains n space-separated integers x1,?x2,?...,?xn (0?≤?xi?≤?100), the price of a honey barrel on day i.

        Output

        Print a single integer ? the answer to the problem.

        Sample test(s)

        input

        5 15 10 7 3 20

        output

        input

        6 2100 1 10 40 10 40

        output

        97

        input

        3 01 2 3

        output

        Note

        In the first sample the bear will lend a honey barrel at day 3 and then sell it for 7. Then the bear will buy a barrel for 3 and return it to the friend. So, the profit is (7 - 3 - 1) = 3.

        In the second sample bear will lend a honey barrel at day 1 and then sell it for 100. Then the bear buy the barrel for 1 at the day 2. So, the profit is (100 - 1 - 2) = 97.







        解題思路:題目實質(zhì)是 給一序列,找出后一個與前一個差距最大的值,并且結(jié)果要減去C。直接貪心加暴力,先掃一遍, 找出相鄰元素中后一元素和前一元素差值最大的ans,如果ans < C ,則 ans = 0; 否則 ans = ans - C.






        AC代碼:

        #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x7fffffffint main(){ #ifdef sxk freopen("in.txt","r",stdin); #endif int n, c, a, b; while(scanf("%d%d",&n, &c)!=EOF) { int ans = 0; a = 0; for(int i=1; i<=n; i++){ cin>>b; if(a-b > ans) ans = a-b; a = b; } if(ans > c) ans -= c; else ans = 0; cout< 
        
        
        
        
        

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        CodeforcesRound#226(Div.2)ABearandRaspberry_html/css

        CodeforcesRound#226(Div.2)ABearandRaspberry_html/css_WEB-ITnose:題目鏈接:Bear and Raspberry Bear and Raspberry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output
        推薦度:
        標(biāo)簽: () div.2 raspberry
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲制服丝袜第一页| 77777_亚洲午夜久久多人| 亚洲aⅴ天堂av天堂无码麻豆| 182tv免费视视频线路一二三| 亚洲伊人久久大香线蕉苏妲己| 久久99免费视频| 亚洲AV人人澡人人爽人人夜夜| 无码精品一区二区三区免费视频| 亚洲va在线va天堂va不卡下载| 免费国产叼嘿视频大全网站| 亚洲一区二区在线视频| 18观看免费永久视频| 国产亚洲精品bv在线观看| 国产在线观看免费完整版中文版| 国产一区二区三区亚洲综合| 亚洲综合国产精品第一页| 国产在线观看免费视频软件| 亚洲成熟xxxxx电影| 野花高清在线电影观看免费视频| 亚洲日韩AV无码一区二区三区人| 免费一级一片一毛片| 在线看片免费人成视频久网下载 | 一本天堂ⅴ无码亚洲道久久 | 免费又黄又爽的视频| 色www永久免费网站| 亚洲人成网站日本片| 国产成人免费永久播放视频平台| 国产裸体美女永久免费无遮挡| 亚洲成AV人片一区二区| 中文字幕人成无码免费视频| 污污免费在线观看| 亚洲今日精彩视频| 国产免费怕怕免费视频观看| 成人久久免费网站| 亚洲中文无码永久免费| 亚洲夜夜欢A∨一区二区三区 | 亚洲精品视频免费观看| 香港a毛片免费观看| 欧美日韩亚洲精品| 亚洲精品人成在线观看| 国产色爽女小说免费看|