Someone's Intermediate Representation

0%

Actually, I unfortunately failed in round1. But I find algorithm hacker cup interesting. I wrote some codes as the solutions for this round. Hope you enjoy it.

Pie Progress

• We can see that, if he buy pie number $n$ on one day, then he have to pay another $n^2$ money.

Then according to $\sum (2k + 1) = k^2$, we know that we can sort the every day’s pie price, then add odd number to it.

When buying the pies, since it is pre-sorted by the code, adding odd number in growing order to it does not influence the sequence.

• Another point need to remember is that: one can not buy a pie that is preceding his day.

For example: if he is on the first day, then he should only buy pies on the first day, rather than pies on the second day or even later.

So here is the code. Hope you enjoy.