cy
BAN USER
the ith number in level x 's index is :
(x-1)*x/2 + i, and it's child is (x+1)*x/2 +i, (x+1)*x/2 + i +1;
use the same method just like lucas.eustaquio .
int cup_pyramid(int c, int l, int kth)
{
double a[kth*2+3];
for(int i=0; i<sizeof(a)/sizeof(double); i++)
a[i] = 0.0;
a[1] = l;
for(int level=1; 1; level++)
{
int pos = level*(level-1)/2;
int nextpos = level*(level+1)/2;
int haveover = 0;
for(int index=1;index <=level;index++)
{
if(a[pos+index] - c > 0.00001) {
double over = (a[pos+index] -c )/2;
a[pos+index] = c;
a[nextpos+index] += over;
a[nextpos+index+1] += over;
haveover = 1;
}
}
if(pos > kth) break;
if(!haveover) break;
}
return a[kth];
}
RepLisaTQuinn, Analyst at A9
I have a passion for reading and creative writing and attend many workshops and conventions surrounding love spell that work ...
RepAvyuktBurk, photographer at Precious Moments
Confident and dedicated photographer with experience in both professional and freelance photography. I like to explore Black Magic Spell To ...
Repirmajrichh, Junior programmer at AppNexus
I am Irma, seeking the position of a Historical Researcher at Littler’s where my expertise can be utilized to ...
Repeddieroonie, Member Technical Staff at BMO Harris Bank
I am Eddie, documentation specialist , responsible for creating, updating and maintaining the integrity of organizational instructional documentation. I also love ...
Repjennifertkramer, AT&T Customer service email at ADP
I had a dream to open my own Restaurant in FL. and i came true all dream with my hard ...
RepRuhi Joshi, Java Developer at GrubHub
I am working as an Office support team leader in Gulgowski, Terry and Jenkins. I love health and beauty. I ...
RepEllaFlores, Associate at Alcatel Lucent
Ella , a Tour bus driver in Sounds Great company Inc. A charter bus driver is responsible for providing comfortable and ...
Repkayegoinsk, Cloud Support Associate at ABC TECH SUPPORT
Hello, I'm Kim Starns. I work as a Telephone service representative at the respected Sholl's Colonial Cafeteria. Part ...
Repsusancmeans, Apple Phone Number available 24/7 for our Customers at Absolute Softech Ltd
I am Susan from Bronx, I am working as a Business management analyst in Brendle's company. I Have a ...
Replisapyara, abc at 247quickbookshelp
I am motivated and organized professional with proven years of experience in mail services and industry having vast experience as ...
Repannawellson007, Area Sales Manager at 8x8
Hey my name is anna And i am working as a content writer in Search engine optimization company.My component ...
Repsharoneruther, AT&T Customer service email at ABC TECH SUPPORT
I am Sharon, from Bethlehem USA. I am working as a Park naturalist in Sammy's Record Shack company. I ...
Repjenniferdray9, Accountant at ABC TECH SUPPORT
Hi I am Jennifer D. Ray from san Diego.Currently i am working as a parts salesperson in Rite solution ...
Repamayahoyle, Associate at ABC TECH SUPPORT
Working as a Set Designer with 2+ years of experience in Audio Aid for vehicles and props including turns using ...
RepRuthMitchell, Applications Developer at ASAPInfosystemsPvtLtd
My name is Mitchell working as a technical sales support worker in the USA. I identify and establish new business ...
Repharoldjmaloney, Accountant at ASU
Hi, I am a Computer systems administrator from texas. Experienced in running a wide variety of software development Company. Looking ...
Repemilinarula, Dev Lead at ABC TECH SUPPORT
Hi, i've been spotting for about 4 years.Teamwork: works well as a member of a team, pitches in ...
RepI am Rasha , C/C++ certified Computer Programmer with expert-level competency in JavaScript, HTML and JSP and more than 6 ...
Repdebbiewilsond, Software Trainee at Electronic Arts
I am Debbie from Nashua in Us.I Done my study from Us university .Now I am working in Science ...
RepRobin has more than 26 years of experience working for state, city, university, and public entities as a fisheries ecologist ...
Repcherylbgrant, Python Experienced at Bankbazaar
Je suis Cheryl, une traductrice multilingue passionnée avec 3 ans d'expérience dans la traduction de différentes langues telles que ...
Repalicegpopa, Apple Phone Number available 24/7 for our Customers at AMD
I am working as a U.S. marshal in Pro Property Maintenance. I want to write about I Want My ...
RepRileyAllen, Analyst at British Telecom
I enjoy spending my spare time outside and engaging in activities such as hiking, swimming, biking, and jogging. Explore new ...
RepHey, I am Margaret Salas, and I am working as a Web Developer Manager. And nowadays I am doing a ...
Reptaylamowll, Analyst at AMD
Aspire to work in a challenging environment, where my exceptional skills and abilities are completely explored, and I can easily ...
RepLizaZeiger, Animator at Accenture
I am a Loan processing clerk. My work is assembling, administering and processing your loan application paperwork before it gets ...
Reploragurrero, Research Scientist at Absolute Softech Ltd
I am Lora , an empathetic and dedicated Community Organizer with a deep passion for helping others and a strong determination ...
RepGinaSanchez, Computer Scientist at Autoportal.com
Ginna from New York.Successfully managing a high volume of work assignments without compromising quality to exceed client expectations.Apart ...
Repnnatashanaomi, Android test engineer at 247quickbookshelp
I am Marketing managers who play a crucial role in helping a business to promote and its customers. I manage ...
RepGiannaDavid, Author at The times
I am an Author, I have a passion for reading and creative writing and attend many workshops and conventions surrounding ...
Repteresawells858, Java Developer at 247quickbookshelp
I am Teresa. I work as a Software engineer at Asian Fusion Company. I was born in the US and ...
For part 1 of the problem, use min-heap of size k.
- cy August 14, 2013For part 2 of the problem,
1. get the first k number from the stream, and the smallest number of these k number, say mink
2. store the first k number into temp file
3. continue scan the stream, put the number larger than mink into memory buffer
4. if memory buffer is full (size larger than m), merge the buffer into temp file
1. only keep the top k larger number
1. get the new mink (k-th large number)
5. empty the memory buffer, go back to step 3 until the stream end