• <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 閱讀(220) 評論(0)  編輯 收藏 引用
            <2009年1月>
            28293031123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲国产成人久久精品影视 | 国产精品久久久久久影院| 日韩人妻无码精品久久免费一| 亚洲va国产va天堂va久久| 精品精品国产自在久久高清| 无码乱码观看精品久久| 久久av无码专区亚洲av桃花岛| 国内精品久久久久久久久电影网| 久久久久亚洲AV片无码下载蜜桃| 久久综合狠狠综合久久激情 | 久久人人爽人人爽人人片AV高清 | 无码八A片人妻少妇久久| 99久久777色| 久久精品国产免费观看| 久久av高潮av无码av喷吹| 久久亚洲中文字幕精品有坂深雪| 人妻无码久久精品| 热99re久久国超精品首页| 亚洲精品白浆高清久久久久久| 久久久久久极精品久久久| 精品少妇人妻av无码久久| 丁香色欲久久久久久综合网| 久久精品免费网站网| 久久精品国产亚洲沈樵| 色综合久久久久无码专区| 综合久久一区二区三区 | 深夜久久AAAAA级毛片免费看| 69久久精品无码一区二区| 日日噜噜夜夜狠狠久久丁香五月| 久久久久久久免费视频| 久久精品国产一区二区电影| 精品久久久久久久久久中文字幕 | 国产亚洲精品美女久久久| 久久九九久精品国产免费直播| 麻豆久久| 久久久精品国产免大香伊 | 久久99国产精品久久99小说| 欧美日韩成人精品久久久免费看 | 久久久久久精品无码人妻| 久久无码AV一区二区三区| 久久精品国产免费观看 |