DELISH - Editorial

Cannot figure out what’s wrong…Please Help…
http://www.codechef.com/viewsolution/2279041

@sid4art i did the same thing and got WA!
http://www.codechef.com/viewsolution/2276586

Can someone please point out what is wrong with this approach?

http://www.codechef.com/viewsolution/2299047

Can anyone tell whats wrong in this code???

By same reasoning , one can implement Kadane algorithm too.

Can anyone explain me the output for
5
10 3 1 2 9

The output according to setter’s or tester’s code is 12. How?

@dsahapersonal assuming t=1,n=5,d={10,3,1,2,9}, that is the correct answer ! We need to basically find two contiguous subarrays (no intersecting point) such that the absolute difference(if the diff is negative,it turns positive) between the sum of each subarray is maximum .Now,the main thing to note here is that the length of the subarray could also be 1. Therefore , if you consider these two subarrays : {10,3} and {1} then the difference is absolute(1-(10+3))=absolute(-12) = 12 ! Also if you take any other pair of subarrays ,you will find that the absolute difference is not greater than that.

The sixth function is wrongly written. It should be leftmost not rightmost.

HardRightMax(i) = Maximum value of the sum of a contiguous subarray whose leftmost point = i.

The above solution provided in tutorial is giving tle while submitting in the java and the same solution give ac while submitting in java why?
Java Solution->https://www.codechef.com/viewsolution/21872923
C++ Solution->https://www.codechef.com/viewsolution/21872897

Not really. In your example, you say LeftMin(j) - RightMin(j+1) is larger. But note that LeftMin(j) <= LeftMax(j). So your case will be considered (and potentially bettered) in the check for LeftMax(j) - RightMin(j+1). You can check that the same will happen with comparing other pairs - wherever you compare difference of “max with max” or “min with min”.

2 Likes

really… that annoying… coding right… it’s better to understand someother code(esp. above tutorial) than that purely written code…

same story… here :-/

haha… I knew it bro… I was jst thinking, in what world karlheinz would be, when he wrote the code… I mean how a person can write such a code… I think he himself cant xplain that…

1 Like

think it this way… Compare your present knowledge with the knowledge you had when you started competitive coding… we all know that it must be way better than at that time… Now you are a part of a dedicated community whose members are not only working for themselves but are working for each other… At least you are better than your mates who dont even knw a bit about competitive programming… At least we try our best to solve these tuff problems and become part of a big competitions… Cheerup bro these conditions will reoccur… all what we need is unstoppable efforts… :wink:

4 Likes

Well, @devanshug, you’re right and it is indeed a lot better now than it was before… I even got to write some Simple problems as a setter and I actually think I managed to write good tutorials here on forums… But sometimes I feel that this is all I got… Maybe it’s the lack of time that makes me think this way, but it’s still very frustrating and demotivating… I think I will try to work as hard as university allows me, in order to get a little bit better though :slight_smile: Thanks for your words

1 Like

dafaq is this code !!!whre’s a main() ??

1 Like

@kuruma, Being relatively new to competitive programming and algorithms besides the constraints due to university, i feel the same as i have not been able to solve more than 3 problems but each time we get stuck we learn something new(be it the simplest of things) but that is what should drive us as these little things go a long way in enhancing our programming skills. Bit by Bit, Bytes of knowledge can be acquired, learnt and applied to improve our speed and efficiency in solving more problems. And considering that you are a lot better than before, its an achievement in itself. Chin up!

2 Likes

@spandanpathak, It has a main… but nothing else is understandable. Probably we first need to replace all those variable to simple ones and the format it to understand where the functions start and end… :stuck_out_tongue:

That code gives me urges that he must have done something which he is hiding behind that dirty code :slight_smile:

1 Like

@shashank_jain: I always prefer akash4983’s code for this purpose . least use of templates , least use of all the big constructs and more of a simple oriented approach devoid of problems associated with using abs , fabs , mods etc.

It’s natural to feel this way maybe you were trying too hard…but as @devanshug said compare your knowledge now with what you have when you started…Key is to keep practicing…and C’mon you are the one who wrote questions like FCBARCA and CLBMSTRS which I loved to solve…these are way too creative…simple series questions hidden behind very creatively created stories…AWESOME MAN AWESOME!!! Happy Coding:-)

2 Likes