Hello, Codeforces!

We're going to host a new contest at csacademy.com. Round #80 will take place on Wednesday, 23 May 15:05 (UTC).. This contest will be a Div1 + Div2, with **7** tasks of varying difficulty that need to be solved in **2** hours.

**Some of the problems will be based on contests from Romanian Olympiad IOI selection camp.**

#### Facebook event

We recently created a new Facebook event. If you choose "Interested" here, you will be notified before each round we organise from now on.

#### Contest format:

- You will have to solve
**7**tasks in**2**hours. - There will be full feedback throughout the entire contest.
- Tasks will not have partial scoring, so you need to pass all test cases for a solution to count (ACM-ICPC-style).
- Tasks will have dynamic scores. According to the number of users that solve a problem the score will vary between 100 and 1000.
- Besides the score, each user will also get a penalty that is going to be used as a tie breaker.

#### Prizes

We're going to award the following prizes:

- First place: 100$
- Second place: 50$

#### About the penalty system:

- Computed using the following formula: the minute of the last accepted solution + the penalty for each solved task. The penalty for a solved task is equal to log2 (no_of_submissions) * 5.
- Solutions that don't compile or don't pass the example test cases are ignored.
- Once you solve a task you can still resubmit. All the following solutions will be ignored for both the score and the penalty.

If you find any bugs please email us at contact@csacademy.com

Don't forget to like us on Facebook, VK and follow us on Twitter.

Just a reminder, the contest starts in an hour. ☺️

We waited for this contest 2 weeks :(

Seems like they simply waited, too.

Took second place and round is unrated :(. At least I will keep

thisrating which certifies my right to hold my current nickname :P (but it's hermetic joke)In case anyone is wondering, reference about Swistakk's long tradition with second place.

But you'll get those 50 bucks, right? Right?

I submitted, got a compilation error, didn't know what is wrong and resubmitted the same code (with a semicolon added because otherwise the system wouldn't allow me) and got AC. You might want to check that to avoid the issue in the future. Submission ID's are 1580921 and 1581103. Cheers.

I'll get that checked out. It seems one judging machine was making weird problems. BlueMarry signaled the same thing as well. Definitely gonna check it out. Thanks

I just finished the editorial for problem anagram-sort. I really like the problem so I wanted to share the editorial with everyone. Even thou it's a long editorial, I hope it'll be easy to understand. Personally, I hope you'll enjoy the problem as much as I did.

The rest of the editorials will be coming in the following days. I have some exams at the university in this period so they'll be delayed a little bit.

Also, I'll be writing a post-morted regarding round-80 so others wouldn't do the same mistakes I did.

Lol, I didn't note that n circular shifts is the same thing as 0 circulars shifts (which was first question in my code), so in my initial thought I needed n+1 questions for determining answer (for 0, 1, ..., n shifts) and next one for stating the answer which is n+2 queries and I needed to get rid of one query. I noted that if I get rid of last real query (not one stating answer) then I am able to get to know n-1 positions, so I can determine position of last element by seeing where is the only one not filled gap ;p.

This was my first idea as well. I found out later that you actually make circular shifts and there are only N of them.

It's funny because in the olympiad version you would have to specifically say "this is the solution" and I had a bug where I accidentally discovered the solution while doing the circular rotations.

How to solve shampoo exchange ?

It's quite complicated for C. If you need to clear

xbottles intoy(fullest) bottles andx≤y, the answer is the volume in the fullest of thesexbottles. Otherwise, take the fullestybottles out ofxand remember their sizes in a multisetS_{1}; also, remember a numbersdenoting that everything in that multiset actually had volumesalready subtracted from it, and store the remainingN-x-ysmallest bottles in another multisetS_{2}.Now you can simulate. You either transfer enough shampoo from

S_{1}to theybottles to fill up the last (initially fullest) of them completely, in which case you can remove it and continue withy— note that you need to move a bottle fromS_{1}toS_{2}in that case — or enough to empty the smallest bottle fromS_{1}, in which case you delete it and move a bottle fromS_{2}toS_{1}— if you're movingafromS_{2}, you're movinga+stoS_{1}, so thatswould make sense for this bottle as well. Updatesby adding to it the transferred volume in this step.In the end, you reach

y= 0 orx≤y, at which point you can add tos, which actually represents the total time.