Same here buddy. My entire time whooshed away in those if else. BTW, check out this solution, you might like it-
Hereās the simulation of first 7 days for your TC. Set dif = 0, count = 0,
Day 1:
diff = diff+10-8 = 2, count = 1
Day 2:
diff = 2+10-8 = 4, count = 2
Day 3:
diff = 4+10-8 = 6, count = 3
Day 4: diff = 6+10-8 = 8, count = 4
Day 5: diff = 8-8 = 0, count = 4 Your mistake, as you didnāt buy this day and later on concluded insufficiency of sweets.
Day 5: diff= 8+10-8 = 10, count = 5
Day 6: diff = 10+10-8 = 12, count = 6
Day 7: diff = 12-8 = 4, count = 6.
Hope this makes clear.
And to all who read this comment, if stuck in a simulation, use print statements to do all this.
Very much liked it @vijjju123 !! Just loving itā¦
A 200-line solution shoved under the nose of an innocent boy.
Though your solution is nice one, it have a worse Time complexity of O(Slog(7*S)) while above mentioned solution has time complexity of O(S).
You can improve your check function to work in O(1) by a simple change, and even shorter code.
I think binary search is an overkill here. But well, Binary search is <3 .
Initially I waited for few mins before coding and then I saw multiple WAs,so I thought O(S) might be missing some corner cases. I was sure about BS solution,so implemented it
Lol, I was hunting for cakewalk problem in first few min my order was-
>Opened p4. ".....He asked to find the matrix? DEFINITELY NOT CAKEWALK"
>p5 has "graph" in it. Lol graph no cakewalk.
>Great array...hmmm. Might be. (2 min after reading the statement and thinking "Noo....please this be p4.....XD
>Multhree "YEAH This can be cakewalk!!" (Submitted a soln- got WA- "Hmm...Not cakewalk I guess lol")
>And finally chocoland lol.
#DP_Intensifies
Happened with me too.
I think it was an overkill here btw thanks.
Lmao yeah XD. If anything, my solutions always find something in the cook off :3 . The most hilarious was, when my brute force got accepted in p3 XD (I think @kingofnumber was the setter of that one)
Its not hard to miss Invitation for January Cook Off, 2018 - general - CodeChef Discuss
Invitation threads, by default, are feedback threads as well.
more than 75% solutions of SURVIVIE would have failed if only the corner cases were designed properly.
Yup, I did expected a corner case somewhere on lines of not buying on sunday giving -1. But I think those cases also have N<K or some other condition which made them weaker- and hence lack of an individual case with this feature alone.
BTW, do discuss that in feedback thread, the setter will value your insight surely.
Didnāt get that.
It fails on the corner case of ā9 8 10ā where it should print -1. Lucky that cases were weak