A set of NOIP simulation

Source: Internet
Author: User
Tags sort
Transmission Door

http://218.28.19.228/cogs/problem/problem.php?pid=2064
http://218.28.19.228/cogs/problem/problem.php?pid=2065
http://218.28.19.228/cogs/problem/problem.php?pid=2066 T1 Mountain climbing topic

Given the initial position, the amount of time that can be spent, the last position, and the maximum distance of each move (up or down ), ask the maximum number of questions that can be reached

We draw pictures to think about, in fact, it is hard to climb up and then try to crawl down to the final position, time within the provisions of the good, so we two points to the answer is OK
Enumeration Ans,⌈ans−ad⌉+⌈ans−bd⌉<=n Enumeration Ans,\lceil\frac{ans-a}{d}\rceil+\lceil\frac{ans-b}{d}\rceil
Rounding up can have techniques that are not discussed, such as ⌈ans−ad⌉\lceil\frac{ans-a}{d}\rceil, which can be written as ((Ans-a-1) div d) +1
Note that two points do not get stuck!
Note that two points do not get stuck!
Note that two points do not get stuck!
Two points really really really is really very easy to hang things ...

var
 tt,l,r,mid,n,d,a,b:int64;
function Check (ans:int64): Longint;
Begin
 Tt:= (ans-a-1) Div D; Inc (TT);
 if (N-TT) *d+b>=ans then
 exit (1)
 else exit (0);
End;

Begin
 Assign (input, ' mountain.in '); Assign (output, ' mountain.out '); reset (input); rewrite (output);
 READLN (N,D,A,B); Dec (n);
 L:=a; R:=d*n+a;
 While l<r do
  begin
   mid:= (l+r) Div 2;
   If check (mid) =1 then
   l:=mid
   else r:=mid-1;
   If L+1=r then break;
  End;
 If check (r) =1 then l:=r;
 Writeln (l);
 Close (input); Close (output);
End.
T2 Number of studies Main Topic

Given the sequence of n number, it has n∗ (n+1) 2 sub-sequences, take out the maximum value of each sub-sequence, Q asks the number of numbers less than/equal to/greater than K given n number of sequences, it has \frac{n* (n+1)}{2} subsequence, take out each sub-sequence of the maximum value, Q ask less than/equal to /number of numbers greater than K

This question is actually very good to think, but the examination time I have written until the end has not handled the two points discussion, yes, again two points ...
OK, let's talk about how to do it
we found that the number is only the number of the N, but the number of numbers there is a difference, so we think of ways to deal with the number of each count, in fact, the equivalent of each number of contributions, each number to the side of the expansion until larger than its number appears, Just like a row in the maximum total of 0 sub-matrices, we use a monotone stack easy to handle, but we from the data range of hints found that the number of repetitions, that is, the extension of the time there is equal, I think in the exam is the first discretization, processing and then discretized back, in fact, no repetition is x[k]< x[i] < X[j], repeat to put one side of the equal sign can be .... Because the same number in the same interval effect is the same, and the idea of discretization is the same as the rule of which the same large, while taking the other is directly using their array subscript to limit,
query when the two minutes is good, How to find the two points in fact I am not quite clear, because I do not think the two-point discussion of the extent of my writing, and so I ask God Ben after the write it again

Const maxn=100050;
 var t,l,r,x,z:array[0..maxn]of longint;
 Sum,y,ans:array[0..maxn]of Int64;
 I,j,k:longint;
 N,q,len,tt,ll,rr,mid,pp:longint;
Ch:char;
Procedure sort (l,r:longint); var i,j,a,b:longint;
C:int64; Begin I:=l; J:=r;
 a:=x[(l+r) Div 2];
  Repeat while X[i]<a do Inc (i);
  While A<x[j] do Dec (j); If not (I&GT;J) then begin b:=x[i]; X[I]:=X[J];
    X[j]:=b; C:=y[i]; Y[I]:=Y[J];
    Y[j]:=c; Inc (I);
   Dec (j);
 End
 Until i>j;
 If L<j then sort (l,j);
If I<r then sort (i,r);

End Begin assign (input, ' jxthree.in '); Assign (output, ' jxthree.out '); Reset (input);
 Rewrite (output);
 READLN (N,Q);
 For I:=1 to n do read (X[i]);
 READLN; T[1]:=1; L[1]:=1; Len:=1; t[0]:=0;
 X[0]:=maxlongint;
   For i:=2 to n do begin tt:=0; For J:=len downto 0 "do if X[I]&LT;X[T[J]" then begin L[I]:=I-T[J]; Tt:=j; Break
   End Else R[T[J]]:=I-T[J]; len:=tt+1;
  T[len]:=i;
 End
 For I:=1 and Len do r[t[i]]:=n+1-t[i]; For I:=1 to N do Y[i]:=int64 (L[i]) *int64(R[i]); Sort (1,n); len:=0;
 X[0]:=-1; For I:=1 to N does if X[I]&LT;&GT;X[I-1] then BEGIN Inc (LEN); Z[len]:=x[i];
 End
 tt:=0;
   For I:=1 to n does begin if X[I]&LT;&GT;X[I-1] then Inc (TT);
  Inc (Ans[tt],y[i]);
 End
 sum[0]:=0;
 For I:=1 to n do sum[i]:=sum[i-1]+ans[i]; For i:=1 to Q do begin READLN (CH,K);
   pp:=0;  If K>z[len] THEN BEGIN case CH

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.