AkeenL's blog

By AkeenL, history, 3 years ago, In English

I was doing https://codeforces.com/contest/1420/problem/C1 which is a max sum alternating subsequence problem. I understand the dp solution but I fail to understand why adding the first number in the array then adding every positive arr[i] — arr[i-1] works if you have to choose numbers starting from the first element.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By AkeenL, history, 3 years ago, In English

For problem BerPizza https://codeforces.com/contest/1468/problem/C the most easy solution is to store the key and values in a hashmap and loop through looking for either largest value or smallest index. This approach gives TLE and when I read the editorial they recommend a treeset but a treeset cannot store duplicate values. Is there a way to iterate through a map faster than o(n) or do I need to use priorityqueues for this problem?

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By AkeenL, history, 3 years ago, In English

Recently I've begun taking CP more seriously and practicing every day. I've been able to get to around 1100 but can't get past that. I've started trying 1100 and 1200 rated problems as those are the ones I struggle to solve in contest. With these problems I've noticed the solution is almost always simple but there's some key observation needed to be found in order to solve them (especially in math).I wanted to know if there's any particular way I should be thinking about and approaching these problems. Or are these observations just something picked up after many problems solved?

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it