• <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 閱讀(211) 評論(0)  編輯 收藏 引用
            <2009年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            2020最新久久久视精品爱| 韩国无遮挡三级久久| 久久精品国产99久久久古代| 青草国产精品久久久久久| 国内精品伊人久久久久影院对白 | 久久偷看各类wc女厕嘘嘘| 精品精品国产自在久久高清| 日产久久强奸免费的看| 777米奇久久最新地址| 亚洲伊人久久成综合人影院 | 久久最近最新中文字幕大全 | 国产成人精品免费久久久久| 久久精品国产一区二区三区| 狠狠88综合久久久久综合网| 久久伊人亚洲AV无码网站| 久久香蕉国产线看观看99| 无码伊人66久久大杳蕉网站谷歌| 久久久久无码国产精品不卡| 99久久精品国内| 久久中文骚妇内射| 热re99久久精品国99热| 久久天天躁狠狠躁夜夜avapp| 久久久久亚洲AV成人网人人网站| 久久99久久99精品免视看动漫| 尹人香蕉久久99天天拍| 久久久久成人精品无码| 久久91精品国产91久久户| 国产精品美女久久久m| 国产成人久久精品一区二区三区| 久久综合给合久久国产免费| 国色天香久久久久久久小说 | 99久久国产主播综合精品| 国产精品国色综合久久| 久久99精品久久久久婷婷| 久久精品国产亚洲av麻豆色欲| 久久中文字幕人妻熟av女| 久久99这里只有精品国产| 色播久久人人爽人人爽人人片AV| 国产99久久久国产精品小说| 久久无码专区国产精品发布| 久久久久av无码免费网|