Блог пользователя theAyconic1

Автор theAyconic1, 3 года назад, По-английски

Hi Everyone,

I gave my first ever contest on codeforces recently which was Codeforces Educational Round 151 and I am really happy to become rated. The problems felt really good, I was able to solve A,B and C during the contest and later I was able to upsolve D. I also placed 2530. Since this was my first contest here I would like to make it special by thanking the creators of this round namely adedalic , BledDest , Neon and awoo with all my heart via this blog. Thank you so much guys, keep up the good work !

Полный текст и комментарии »

  • Проголосовать: нравится
  • +50
  • Проголосовать: не нравится

Автор theAyconic1, 3 года назад, По-английски

The problem statement can be referred from here. In short you are given an array "prices" and you need to determine the maximum profit one can earn by doing atmost k trades. You cannot buy a stock unless you have sold the previous one. The dynamic programming solution to this is well known and solves the problem in O(nk) time but did you know a stack+heap solution to this also exists that solves the problem in O(n+nlogk) time? This second solution is not as famous and I have only ever managed to find 2 or 3 articles explaining the solution and that too were not very clear and full of symbols instead of a visual explanation. So here in this article I will try to explain this solution as clearly as I can.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится