×

# [closed] Plz help solving COOLING Problem??....newbie to codechef

 0 Guys, I have tried solving Cooling problem with many inputs and I even get the desired output on my pc, but still getting "wrong answer" on code chef. Here is my code. asked 23 Sep '13, 00:12 10●1●1●3 accept rate: 0% 4★kunal361 6.0k●13●32●72

### The question has been closed for the following reason "The question is answered, right answer was accepted" by kunal361 09 Dec '13, 10:02

 1 in your bubble sort code u r also considering a[n] when i=0 and j=n-1. so if a[n] is initiated by previous test cases then your code will fail. i just initiated a[n] to 1000000000 and submitted your code and got accepted. my submission http://www.codechef.com/viewsolution/2707109. also a small suggestion try to use std::sort() and std:swap() in your code. answered 23 Sep '13, 08:26 470●4●5 accept rate: 40% didn't get? how code fails if a[n] initiated by previous test case??...It would be pretty kind of you to explain me out in this regard..........newys thanks bro for your useful suggestion :) (23 Sep '13, 22:49) 1 consider the test case 2 4 1 10 20 30 1 10 20 30 3 10 20 30 10 20 30 ->for first test case in bubble sort code a[4] is also considered while sorting but a[4] is not assigned any value so it considers a garbage value for a[4]. after first test case execution wr[]-> "0 0 0 0". ->for second test case after input wr[] -> "10 20 30 0" after sorting wr[] -> "0 10 20 30"(since you are also considering a[3] which is assigned value 0 instead of getting "10 20 30 0" your wr[] will be "0 10 20 30". so the ans will be printed as 2 instead of 3. hope this helps :) (24 Sep '13, 06:28) thnkx bro..got it..:) (26 Sep '13, 01:00)
 0 i'm not into c language, but the potential reason why you might be getting WA, is the special cases which you need to think about separately and then handle. also while testing your code on pc, you might not be testing it for those cases hence getting right answer. So, think again, this time a little deep. -all the best answered 23 Sep '13, 01:42 85●5●8●17 accept rate: 0%
 1 Hey change bubble sort to quick sort i have done same in your code and got AC you can see my submission http://www.codechef.com/viewsolution/2706803 answered 23 Sep '13, 02:10 31●1●1●5 accept rate: 0%
 0 NOTE: in my opinion, it would be nice if you count++ inversely. assume weight is X, and limit is Y func respectively. we have(or reach) our desired count++ when Y's element is bigger than or equal to X's particular element. and in that condition we count++. otherwise, we just pass onto Y's next element, till we meet the condition. answered 09 Dec '13, 10:00 1★garakchy 1.1k●16●30●48 accept rate: 1%

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,698
×169
×29

question asked: 23 Sep '13, 00:12

question was seen: 996 times

last updated: 09 Dec '13, 10:02