• <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!腦袋天天殘障!愚人節也不能這樣?。∥业腗oney啊  回復  更多評論
              
            # re: Making the Grade
            2009-04-04 01:39 | hello
            能發代碼嗎
              回復  更多評論
              
            # re: Making the Grade
            2009-04-04 06:39 | Knignt
            @hello
            這道題我說了我是看那別人的代碼過的,你百度一下吧,由別人的結題報告  回復  更多評論
              
            <2009年8月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            97久久久精品综合88久久| 99久久香蕉国产线看观香| 精品久久久久香蕉网| 精品久久香蕉国产线看观看亚洲 | 国产伊人久久| 国产午夜福利精品久久| 77777亚洲午夜久久多喷| 国产精品狼人久久久久影院| 亚洲国产成人久久综合一区77| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久久久亚洲AV无码专区体验| 久久精品麻豆日日躁夜夜躁| 国产精品久久久久9999高清| 久久婷婷人人澡人人| 久久夜色精品国产噜噜麻豆| 激情久久久久久久久久| 青青草原综合久久大伊人| 国产精品美女久久久久| 伊人 久久 精品| 久久九九青青国产精品| 18岁日韩内射颜射午夜久久成人| 国产99久久久国产精免费| 一本久久综合亚洲鲁鲁五月天| 成人精品一区二区久久久| 亚洲va久久久噜噜噜久久男同| 色综合久久88色综合天天| 亚洲日本va午夜中文字幕久久| 久久久久免费精品国产| 亚洲中文久久精品无码| 亚洲国产成人乱码精品女人久久久不卡| 亚洲av成人无码久久精品| 久久九九久精品国产免费直播| 99久久er这里只有精品18| 久久久久国产精品三级网| 69SEX久久精品国产麻豆| 日韩AV无码久久一区二区| 一本久道久久综合狠狠躁AV| 久久综合成人网| 热RE99久久精品国产66热| 久久er国产精品免费观看8| 亚洲午夜久久久精品影院|