• <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)  編輯 收藏 引用
            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久亚洲AV无码网站| 777午夜精品久久av蜜臀| 91精品国产91久久久久久| 成人久久久观看免费毛片| 一本大道加勒比久久综合| 色综合久久中文字幕综合网| 国内精品久久久久影院亚洲| 色欲av伊人久久大香线蕉影院| 97精品伊人久久大香线蕉app| 国产精品免费久久久久电影网| 亚洲精品乱码久久久久久蜜桃| 日产精品99久久久久久| 中文字幕亚洲综合久久| 日韩人妻无码一区二区三区久久99| 国产成人精品白浆久久69| 久久久青草青青国产亚洲免观| 久久久久AV综合网成人| 精品视频久久久久| 精品人妻久久久久久888| 婷婷久久五月天| 精品国产婷婷久久久| 99久久超碰中文字幕伊人| 精品久久久久久中文字幕大豆网| 国产精品青草久久久久福利99 | 久久男人中文字幕资源站| 人妻无码中文久久久久专区| 久久国产乱子伦精品免费午夜| 久久国产高潮流白浆免费观看| 久久人人爽人人爽人人片AV麻烦| 国产精品日韩欧美久久综合| 狠狠88综合久久久久综合网| 亚洲欧洲日产国码无码久久99| 久久久久国产视频电影| 精品久久久久久国产免费了| 国产精品久久99| 久久久久四虎国产精品| 久久国产免费观看精品3| 久久香蕉超碰97国产精品| 久久人人妻人人爽人人爽| 久久夜色精品国产亚洲| 2021久久精品免费观看|