3381: [Usaco2004 Open]cave cows 2 The two cows in the cave

Source: Internet
Author: User

3381: [Usaco2004 open]cave cows 2 The cattle in the cave of the two time limit:10 Sec Memory limit:128 MB
Submit:21 solved:18
[Submit] [Status] [Discuss] There is a long passage in the Description Cave. It is made up of N (1≤n≤25000) segment tails, numbered 1 to n respectively. Each channel has a threshold that ranges in [1,10^9] sequentially through I. J of the channel, the cow's body mass index can not exceed I. The minimum value of the threshold in the J channel. Betsy has a Q (1≤q≤25000) question, and would like to ask you for the minimum value of the threshold of the channel from I to J. Input line 1th inputs N and Q, the next n lines enter the threshold for each channel, followed by a Q line of two integers per line, corresponding to the problem of I and J (i<j). Output outputs its results for each issue. Sample Input10 4
75
30
100
38
50
51
52
20
81
5
1 10
3 5
4 {
8 TenSample Output5
38
20
5HINT Source

Orange

Problem: rmq Template ... Feel yourself water-water da

1/**************************************************************2Problem:33813 User:hansbug4 language:pascal5 result:accepted6Time:272Ms7Memory:2220KB8****************************************************************/9  Ten var One I,j,k,l,m,n,h:longint; AA:Array[0..30000,0.. -] ofLongint; - functionmin (x,y:longint): Longint; -          begin the               ifX<y ThenMin:=xElsemin:=y; -          End; - begin - readln (n,m); +H:=trunc (ln (n)/ln (2)+1); -       fori:=1  toN DoREADLN (A[i,0]); +       fori:=1  toH Do A           forj:=1  toN-TRUNC (exp (LN (2) (*i)) +1  Do atA[j,i]:=min (a[j,i-1],A[J+TRUNC (exp (LN (2) * (I-1)), I-1]); -   -       fori:=1  toM Do -          begin - readln (j,k); -L:=trunc (LN (k-j+1)/LN (2)); inWriteln (min (A[j,l],a[k-trunc (exp (LN) (2) (*l)) +1, l])); -          End; to Readln; + End.

3381: [Usaco2004 Open]cave cows 2 The two cows in the cave

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.