So, if you paricipated in ER 176 and got WA2 on problem B, you might think this is a terrible problem, maybe one of the worst on CF. Let me try to explain why it was created, and maybe it will change your opinion about it (or maybe it won't).
This problem has an obvious solution: you have to maximize the sum of the first $$$k$$$ chosen elements and the last element you paint, so the sum of $$$(k+1)$$$ elements of the array. So, let's take $$$(k+1)$$$ greatest elements, add them up, and we get the answer. It even passes the sample test case, but it is wrong.
When preparing the problem, we had an option to discard the case when this greedy solution does not work. However, I didn't like that version of the problem because it just becomes a "guessforces" problem — people can just assume that you always choose $$$(k+1)$$$ maximums, submit the solution without proving it, and get Accepted. I believe we already have too many problems of this style on Codeforces.
To solve the current version of the problem, you have to actually find out what is wrong with the original idea, locate the case when the greedy solution does not work. I think that proving your solution or finding flaws in your ideas is a very important skill in programming contests, and this situation (when you have a "working" solution which does not pass the tests, and you need to find an issue with it) teaches this skill. This is also why the case when the greedy idea fails is not in the samples — otherwise finding the issue would be too effortless.
Were there any flaws with the problem itself? There was at least one, but it is not in its idea/preparation, but it is a mistake I made during the contest itself. The first global clarification for the problem was poorly worded, so some people assumed that an element has to have exactly two blue neighbours if we want to paint it. This was a mistake, and I am sorry for it. I probably should not have sent it in the first place.
But I still think that such problems should be on CF, especially because most other problems are set in a way that if you have a greedy idea which passes the samples, it passes the actual tests.












