"bzoj4721" [Noip2016] Earthworms

Source: Internet
Author: User

Title Description

in this subject, we will use the symbol [C] to represent the downward rounding of C, for example: [3.0"= [3.1"=[3.9"=3. Cricket the worm has been a disaster recently! Next Door JumpFlea Country Flea also take earthworms have no way, cricket King had to ask God knife hand to help them destroy earthworms. There are now n earthworms in the cricket state (n is a positive integer). Each earthworm has a length, and we set the a_i (i=1,2,..., N) Length of the first earthworm, and ensure that all lengths are non-negative integers (i.e., earthworms with a length of 0 may exist). Every second, the sword hand will accurately find the longest one in all earthworms (if more than one is selected) cut it in half. The position of the worm is determined by the constant p (the rational number satisfying the 0<p<1), which is set to X, and the sword is cut into two earthworms of the length of [px] and x-[px respectively. In particular, if one of the two numbers equals 0, the earthworm with a length of 0 will also be retained. Furthermore, in addition to the two new earthworms that have just been produced, the length of the remaining earthworms increases Q (which is a nonnegative integer constant). King Cricket knows this is not a long-term, because earthworms will not only become more and more, but also longer. King Cricket decided to resort to a mysterious figure with a primitive force, but the reinforcements needed m seconds to come ... (M is a non-negative integer) King Cricket wants to know what's in this M-second. Specifically, he wished to know: in M seconds, the length of the worm that was cut off every second (with the number of M) before being cut off? m seconds later, the length of all earthworms (with n+m number). The King of cricket knows what to do! But he wants to test you ...

Input

The first line contains six integer n,m,q,u,v,t, wherein: The meaning of N,m,q is described in the question;u,v,t are all positive integers; you need to calculate your own p=u/v (guaranteed 0<u<v) T is an output parameter, meaning it will be interpreted in the output format. The second line contains n non-negative integers, ai,a2,..., An, which is the length of the initial n earthworms. The adjacent two numbers in the same row are separated by exactly one space. guaranteed 1<=n<=10^5,0<m<7*10^6,0<u<v<10^9,0<=q<=200,1<t<71,0<ai<10^8.

Output

The first line outputs [m/t] integers, in chronological order, output t seconds, 2t seconds, 3t seconds ... The length of the worm being cut off (before being cut off). The second line outputs [(N+M)/t] integers, outputting the length of the earthworm after m seconds; need to be in order from large to smalloutput rank T, section 2t, 3t ... The length. The adjacent two numbers in the same row are separated by exactly one space. You should output a blank line even if a row does not have any number to output. Please read the sample to better understand this format.

Sample input

3 7 1 1 3 1
3 3 2

Sample output

3 4 4 4 5 5 6
6 6 6 5 5 4 4 3 2 2

Exercises

Queue problem

Since the first tangent of the two segment must be greater than or equal to the corresponding two segments of the tangent,

You can then store [px] and x-[px] segments in two queues, and one store the original length.

Each time the +q length of the cut, equivalent to the length of the cut-Q, and then add together when looking.

Note that a long long is required for division.

Also, on the Bzoj, may be PE countless times, only according to the sample format output, not more than any space and newline.

1#include <cstdio>2#include <algorithm>3 #defineINF 0x7fffffff4 using namespacestd;5 intq[3][8000001], l[3], r[3] = {-1, -1, -1}, a[100001];6 BOOLcmpintAintb)7 {8     returnA >b;9 }Ten intGetmax () One { A     intK =-inf, ans =0; -     if(l[0] <= r[0] && q[0][l[0]] > k) k = q[0][l[0]], ans =0; -     if(l[1] <= r[1] && q[1][l[1]] > k) k = q[1][l[1]], ans =1; the     if(l[2] <= r[2] && q[2][l[2]] > k) k = q[2][l[2]], ans =2; -     returnans; - } - intMain () + { -     intN, M, G, u, V, T, I, p, C; +scanf"%d%d%d%d%d%d", &n, &m, &g, &u, &v, &t); A      for(i =0; I < n; i + + ) atscanf"%d", &a[i]); -Sort (A, A +N, CMP); -      for(i =0; I < n; i + + ) -q[0][++r[0]] =A[i]; -      for(i =1; I <= m; i + + ) -     { inp =Getmax (); -c = q[p][l[p]++] + G * (I-1); to         if(i% t = =0) +         { -             if(I! =t) theprintf" "); *printf"%d", c); $         }Panax Notoginsengq[1][++r[1]] = (int)((Long Long) c * u/v)-G *i; -q[2][++r[2]] = C-(int)((Long Long) c * u/v)-G *i; the     } +printf"\ n"); A      for(i =1; I <= m + N; i + + ) the     { +p =Getmax (); -c = q[p][l[p]++] + G *m; $         if(i% t = =0) $         { -             if(I! =t) -printf" "); theprintf"%d", c); -         }Wuyi     } theprintf"\ n"); -     return 0; Wu}

"bzoj4721" [Noip2016] Earthworms

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.