• <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年2月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲日韩欧美一区久久久久我| 区久久AAA片69亚洲| av无码久久久久久不卡网站| 2021久久国自产拍精品| 狠狠色丁香婷婷综合久久来来去| 久久久久一级精品亚洲国产成人综合AV区 | 亚洲精品无码久久毛片| 亚洲综合伊人久久大杳蕉| 久久综合久久综合九色| 狠狠色丁香久久婷婷综合图片| 久久香蕉超碰97国产精品| 久久这里有精品视频| 丁香狠狠色婷婷久久综合| 国产精品久久久香蕉| 夜夜亚洲天天久久| 亚洲国产精品无码久久久秋霞2 | 性色欲网站人妻丰满中文久久不卡| 久久精品国产亚洲av水果派 | 99久久亚洲综合精品成人| 国产精品乱码久久久久久软件| 久久99精品免费一区二区| 国产亚洲精品自在久久| 久久久久久精品久久久久| 久久久久一本毛久久久| 99久久精品国产一区二区三区| 人妻无码中文久久久久专区| 亚洲精品成人网久久久久久| 久久久久久久亚洲精品| 一本久久a久久精品综合夜夜| 丰满少妇人妻久久久久久| 国内精品伊人久久久久777| 亚洲伊人久久综合中文成人网| 久久精品?ⅴ无码中文字幕| 国产精品久久久天天影视香蕉| 999久久久免费国产精品播放| 99久久精品费精品国产一区二区 | 91精品无码久久久久久五月天| 精品国产一区二区三区久久| www.久久精品| 久久成人永久免费播放| 久久嫩草影院免费看夜色|