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,
diff = diff+10-8 = 2, count = 1
diff = 2+10-8 = 4, count = 2
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 .
thanks alot @taran_1407
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.
Happened with me too.
DP is in the air…
Nice solution @vivek_1998299
I think it was an overkill here btw thanks.
your solution fails too @vijju123
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 https://discuss.codechef.com/questions/121750/invitation-for-january-cook-off-2018
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
@vivek_1998299 could you explain that in a bit simpler way …for noobs like me .