• <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
            Balanced Lineup
            Time Limit: 5000MS Memory Limit: 65536K
            Total Submissions: 5218 Accepted: 2453
            Case Time Limit: 2000MS

            Description

            For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a contiguous range of cows from the milking lineup to play the game. However, for all the cows to have fun they should not differ too much in height.

            Farmer John has made a list of Q (1 ≤ Q ≤ 200,000) potential groups of cows and their heights (1 ≤ height ≤ 1,000,000). For each group, he wants your help to determine the difference in height between the shortest and the tallest cow in the group.

            Input

            Line 1: Two space-separated integers, N and Q.
            Lines 2..N+1: Line i+1 contains a single integer that is the height of cow i
            Lines N+2..N+Q+1: Two integers A and B (1 ≤ ABN), representing the range of cows from A to B inclusive.

            Output

            Lines 1..Q: Each line contains a single integer that is a response to a reply and indicates the difference in height between the tallest and shortest cow in the range.

            Sample Input

            6 3
            1
            7
            3
            4
            2
            5
            1 5
            4 6
            2 2

            Sample Output

            6
            3
            0

            Source

            USACO 2007 January Silver
            至于這道題我也懶得寫什么ST算法了都是O(nlgn)時間度,我直接把2823的線段樹的代碼
            改吧改吧就交上了,一次也ac了,不過時間有點長2s......
            代碼就是上篇文章的代碼
            posted on 2009-02-19 14:54 KNIGHT 閱讀(212) 評論(0)  編輯 收藏 引用

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


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

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品99久久久精品无码| 久久亚洲国产午夜精品理论片| 国产成人精品久久亚洲高清不卡| 久久久久国产成人精品亚洲午夜| 精品国产乱码久久久久软件 | 久久久久国产精品麻豆AR影院| 久久影视国产亚洲| 精品久久久久久国产91| 久久亚洲国产精品成人AV秋霞 | 久久天天躁狠狠躁夜夜2020一| 久久99国产综合精品女同| 中文无码久久精品| 久久婷婷是五月综合色狠狠| 大蕉久久伊人中文字幕| 18岁日韩内射颜射午夜久久成人| WWW婷婷AV久久久影片| 人妻无码精品久久亚瑟影视| 国产一级做a爰片久久毛片| 97久久国产露脸精品国产| 久久久青草久久久青草| 久久精品国产亚洲AV蜜臀色欲 | 精品久久久久久国产牛牛app | 色8激情欧美成人久久综合电| 国产叼嘿久久精品久久| 久久99国产综合精品女同| 少妇熟女久久综合网色欲| 久久亚洲AV永久无码精品| 国产精品gz久久久| 99久久国产综合精品网成人影院| 天天久久狠狠色综合| 国产精品禁18久久久夂久| 欧美午夜精品久久久久免费视 | 99精品久久久久久久婷婷| 免费一级欧美大片久久网| 久久精品成人欧美大片| 久久99精品久久久久久噜噜| 色综合久久中文综合网| 国产亚洲成人久久| 久久久久亚洲AV无码专区网站| 精品久久综合1区2区3区激情| 国产精品久久久久久久久久免费|