• <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,無(wú)語(yǔ)了。。。。。。代碼AC后更新,今天愚人節(jié)大家節(jié)日快樂(lè)!
            -------------------------------------------------------------------------------------------
            代碼不用發(fā)了,我自己都是解題報(bào)告看著AC的,3天一道題!汗。。。。。。。我的DP 啊
            posted on 2009-04-01 10:27 KNIGHT 閱讀(342) 評(píng)論(3)  編輯 收藏 引用

            FeedBack:
            # re: Making the Grade
            2009-04-01 20:53 | Knignt
            我靠,今天上午交的20元手機(jī)費(fèi),下午就剩5塊了,XXX!更不爽的是這道題做了3天了,最后還是以解題報(bào)告結(jié)束!Faint!腦袋天天殘障!愚人節(jié)也不能這樣啊!我的Money啊  回復(fù)  更多評(píng)論
              
            # re: Making the Grade
            2009-04-04 01:39 | hello
            能發(fā)代碼嗎
              回復(fù)  更多評(píng)論
              
            # re: Making the Grade
            2009-04-04 06:39 | Knignt
            @hello
            這道題我說(shuō)了我是看那別人的代碼過(guò)的,你百度一下吧,由別人的結(jié)題報(bào)告  回復(fù)  更多評(píng)論
              

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            <2009年4月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            7777精品久久久大香线蕉| 久久国产精品-久久精品| 色综合久久久久| 中文字幕一区二区三区久久网站| 色悠久久久久久久综合网| 国产亚洲精品美女久久久| 天堂久久天堂AV色综合| 久久国产劲爆AV内射—百度| 无码国内精品久久人妻麻豆按摩| 久久综合色之久久综合| 亚洲日韩欧美一区久久久久我| 免费一级做a爰片久久毛片潮| 亚洲国产成人久久一区久久| 办公室久久精品| 午夜视频久久久久一区| 久久久久久国产a免费观看黄色大片| 国产A级毛片久久久精品毛片| 国内精品久久久久影院优| 国产精品久久久久久福利漫画 | 精品久久久久久国产| 久久综合九色综合97_久久久| 久久天天躁狠狠躁夜夜2020老熟妇| 少妇久久久久久被弄到高潮 | 久久成人小视频| 色偷偷88888欧美精品久久久 | 久久久久国产精品人妻| 亚洲AV成人无码久久精品老人| 精品久久久久中文字幕一区| 日日狠狠久久偷偷色综合0| 伊人久久无码中文字幕| 久久久噜噜噜久久| 亚洲欧美成人综合久久久| 久久久久亚洲AV成人网| 久久人人爽爽爽人久久久| 久久成人永久免费播放| 亚洲Av无码国产情品久久| 久久久久久久尹人综合网亚洲| 久久久久亚洲av综合波多野结衣 | 久久成人18免费网站| 久久久无码精品亚洲日韩按摩 | 久久黄色视频|