• <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 閱讀(339) 評論(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
            這道題我說了我是看那別人的代碼過的,你百度一下吧,由別人的結題報告  回復  更多評論
              
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品视频91| 国产91色综合久久免费| 理论片午午伦夜理片久久 | 青青草原综合久久大伊人| 久久人人爽人人爽人人片AV东京热| 久久久亚洲精品蜜桃臀| 中文字幕无码精品亚洲资源网久久| 欧洲成人午夜精品无码区久久 | 亚洲国产成人久久一区久久| 久久人人爽人爽人人爽av| 久久久精品国产sm调教网站| 国产一区二区精品久久凹凸| 麻豆精品久久久久久久99蜜桃| 99精品久久精品| 中文字幕久久亚洲一区| 嫩草影院久久国产精品| 2020久久精品亚洲热综合一本| 一级做a爰片久久毛片人呢| 99久久做夜夜爱天天做精品| 国内精品久久久久久久涩爱| 99久久99久久精品免费看蜜桃| 欧美亚洲国产精品久久高清 | 久久精品国产亚洲一区二区| 久久天天躁狠狠躁夜夜av浪潮| WWW婷婷AV久久久影片| 伊人久久大香线蕉综合影院首页| 久久不见久久见免费影院www日本| 久久国产精品无码HDAV| 久久精品国产久精国产果冻传媒| 久久本道久久综合伊人| 日本精品久久久久中文字幕8| 久久棈精品久久久久久噜噜| 久久伊人五月丁香狠狠色| 国产女人aaa级久久久级| 国产精品久久99| 国产精品一区二区久久国产| 久久亚洲精品人成综合网| 亚洲国产成人久久综合碰| 人人狠狠综合久久亚洲| 欧美性大战久久久久久| 国产精品中文久久久久久久|