• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 74,  comments - 33,  trackbacks - 0
            Making the Grade
            Time Limit: 1000MS Memory Limit: 65536K
            Total Submissions: 1136 Accepted: 478

            Description

            A straight dirt road connects two fields on FJ's farm, but it changes elevation more than FJ would like. His cows do not mind climbing up or down a single slope, but they are not fond of an alternating succession of hills and valleys. FJ would like to add and remove dirt from the road so that it becomes one monotonic slope (either sloping up or down).

            You are given N integers A1, ... , AN (1 ≤ N ≤ 2,000) describing the elevation (0 ≤ Ai ≤ 1,000,000,000) at each of N equally-spaced positions along the road, starting at the first field and ending at the other. FJ would like to adjust these elevations to a new sequence B1, . ... , BN that is either nonincreasing or nondecreasing. Since it costs the same amount of money to add or remove dirt at any position along the road, the total cost of modifying the road is

            |A1 - B1| + |A2 - B2| + ... + |AN - BN |

            Please compute the minimum cost of grading his road so it becomes a continuous slope. FJ happily informs you that signed 32-bit integers can certainly be used to compute the answer.

            Input

            * Line 1: A single integer: N
            * Lines 2..N+1: Line i+1 contains a single integer elevation: Ai

            Output

            * Line 1: A single integer that is the minimum cost for FJ to grade his dirt road so it becomes nonincreasing or nondecreasing in elevation.

            Sample Input

            7
            1
            3
            2
            4
            5
            3
            9
            

            Sample Output

            3
            搞了幾天了還是WA,無語了。。。。。。代碼AC后更新,今天愚人節大家節日快樂!
            -------------------------------------------------------------------------------------------
            代碼不用發了,我自己都是解題報告看著AC的,3天一道題!汗。。。。。。。我的DP 啊
            posted on 2009-04-01 10:27 KNIGHT 閱讀(340) 評論(3)  編輯 收藏 引用

            FeedBack:
            # re: Making the Grade
            2009-04-01 20:53 | Knignt
            我靠,今天上午交的20元手機費,下午就剩5塊了,XXX!更不爽的是這道題做了3天了,最后還是以解題報告結束!Faint!腦袋天天殘障!愚人節也不能這樣啊!我的Money啊  回復  更多評論
              
            # re: Making the Grade
            2009-04-04 01:39 | hello
            能發代碼嗎
              回復  更多評論
              
            # re: Making the Grade
            2009-04-04 06:39 | Knignt
            @hello
            這道題我說了我是看那別人的代碼過的,你百度一下吧,由別人的結題報告  回復  更多評論
              
            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            丁香五月网久久综合| 国产呻吟久久久久久久92| 国产精品亚洲综合久久| 伊人久久精品无码av一区| 久久伊人精品青青草原高清| 精品无码人妻久久久久久 | 中文字幕乱码人妻无码久久| 久久国产AVJUST麻豆| 99久久这里只有精品| 美女久久久久久| 久久久久久久免费视频| 精品久久久久久国产| 久久人人爽人人人人片av| 久久综合中文字幕| 亚洲国产一成人久久精品| 亚洲精品高清久久| 亚洲精品乱码久久久久66| 久久青青国产| 精品一区二区久久| 精品无码久久久久国产| 麻豆精品久久久久久久99蜜桃| 久久免费的精品国产V∧| 国产免费久久精品99久久| 色欲av伊人久久大香线蕉影院| 亚洲а∨天堂久久精品| 无码人妻久久一区二区三区免费 | 人人狠狠综合久久亚洲| 久久丫精品国产亚洲av不卡 | 99久久婷婷国产综合亚洲| 亚洲伊人久久综合影院| 国产69精品久久久久9999| 91精品国产91久久久久久| 国产产无码乱码精品久久鸭| 亚洲狠狠婷婷综合久久久久| 精产国品久久一二三产区区别 | 国产综合精品久久亚洲| 一本久道久久综合狠狠爱| 免费精品久久天干天干| 77777亚洲午夜久久多喷| 久久国语露脸国产精品电影| 99久久国产精品免费一区二区 |