• <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 閱讀(342) 評論(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年4月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品国产99国产精偷| 久久午夜无码鲁丝片| 色欲久久久天天天综合网精品 | 国产精品美女久久久久网| 国产精品狼人久久久久影院| 香蕉久久夜色精品国产尤物| 久久九九青青国产精品| 久久久精品人妻一区二区三区蜜桃| av无码久久久久不卡免费网站| 深夜久久AAAAA级毛片免费看| 久久99精品久久久久久久不卡| 日韩久久无码免费毛片软件 | 久久国产乱子伦精品免费强| 狠狠色噜噜色狠狠狠综合久久| 久久99精品国产麻豆蜜芽| 欧美熟妇另类久久久久久不卡| 久久综合五月丁香久久激情| 香蕉久久夜色精品国产小说| 久久婷婷激情综合色综合俺也去| 老男人久久青草av高清| 国产精品熟女福利久久AV| 成人国内精品久久久久一区| 久久热这里只有精品在线观看| 久久久久久国产a免费观看不卡| 91精品国产91久久综合| 无遮挡粉嫩小泬久久久久久久 | 久久国产精品99国产精| 久久久亚洲AV波多野结衣 | 久久综合综合久久97色| 久久精品国产亚洲AV无码麻豆| yy6080久久| 免费久久人人爽人人爽av| 久久婷婷五月综合色99啪ak | 91精品国产91久久久久福利| 亚洲中文久久精品无码ww16| 狠狠精品久久久无码中文字幕| 久久精品国产欧美日韩99热| 久久99九九国产免费看小说| 亚洲伊人久久成综合人影院 | 久久免费视频网站| 国产精品va久久久久久久|