Initially the order of problems was A-C-E-D-B. But we were not sure about last two.
This is simple straight-forward problem — you were asked to sort the teams with the following comparator: (p1 > p2) or (p1 = p2 and t1 < t2). After that you can split the teams into groups with equal results and find the group which shares the k-th place. Many coders for some reason used wrong comparator: they sorted teams with equal number of problems by descending of time. Such submits accidentally passed pretests but get WA #13.
Polygon A is convex, so it is sufficient to check only that every vertex of polygon B is strictly inside polygon A. In theory the simplest solution is building common convex hull of both polygons. You need to check that no vertex of polygon B belongs to this hull. But there is a tricky detail: if there are many points lying on the same side of convex hull than your convex hull must contain all these points as vertices. So this solution is harder to implement and has some corner case.
Another solution: cut polygon A into triangles (by vertex numbers): (1, 2, 3), (1, 3, 4), (1, 4, 5), …, (1, n - 1, n). The sequences of angles 2 - 1 - 3, 2 - 1 - 4, 2 - 1 - 5, …, 2 - 1 - n is increasing. It means that you can find for each vertex of B to which triangle of A it can belong using binsearch by angle.
Similarly you can cut polygon A into trapezoids (with vertical cuts). In this case you’ll need a binsearch by x-coordinate.
If the initial array doesn’t contain number x, than you definitely need to add it (that’s +1 to answer). Than do the following. While median is strictly less than x you need to increase it. Obviously the surest way to increase the median is to add a maximal possible number (105). Similarly while the median is strictly more than x, add a number 1 to the array. Constraints are small, so you can add the numbers one by one and recalculate the median after every addition.
Also there is a solution without any cases: while the median isn’t equal to x, just add one more number x to array.
Let’s sort the people by decreasing of shoes size. Observe that when considering the i-th man we are interested in no more than 2 pairs of shoes: with size li and li + 1. It allows solving with dynamics. The state will be (the number of first unconsidered man i, is pair of shoes with size li available, is pair of shoes with size li + 1 available). You have 3 options: leave the i-th man without shoes or sell him a pair of shoes of one of suitable size (if available).
Obvious solution with dynamics: you need to know only how many moves are left and where is the ant. This is 4n states, each with 3 options – most of such solution passes. Observe that the vertices A, B, C are equivalent. This allows writing such solution:
int zD = 1;
int zABC = 0;
for (int i = 1; i <= n; i++) {
int nzD = zABC * 3LL % MOD;
int nzABC = (zABC * 2LL + zD) % MOD;
zD = nzD;
zABC = nzABC;
}
cout << zD;
Also this problem could be solved by log(n) with binary exponentiation of some 2 × 2 matrix into power n.
While the world community of participants of programming contests is waiting with bated breath for the news about new date and place of the Final, we decided not to delay the next round and prepared some problems on the train from Petrozavodsk to Saratov. In preparation were involved Mike Mirzayanov, Artem Rakhov and Max Ivanov. Tasks were translated into English by Maria Belova.
Good luck!
Artem Rakhov and Codeforces team
Hi everyone!
The recent testing round went well. It is expected that everything will run faster. Today's round was prepared by: Mike Mirzayanov, Nickolay Kuznetsov, Ivan Fefer and Maria Belova.
Good luck!
Artem Rakhov and Codeforces team
Good evening!
Soon many of you will have your examinations, and someone even have it now. I wish you excellent marks and many easy exams!
Thanks to Nickolay Kuznetsov, Gerald Agapov and Ivan Fefer for their help in preparation of the round.
Good luck!
Artem Rakhov and Codeforces team
UPD:
- Standings
- Problems
- Winner: ghostof2007
Attention, participants from the Division 1! As a test feature, you can participate in Codeforces Beta Round #32 "out of competition".
Everybody knows, that the 2nd of October - birthday of Mohandas Gandhi. We dedicate today's round to him, and many other great people who were born on October 2 :)
Round was prepared by Mike Mirzayanov, Matov Dmitry and Max Ivanov.
Special thanks to Julia Satushina for translation of statements.
Good luck!
Artem Rakhov and Codeforces team
- Problems
- Final standings
- Winner: Rei
- Solutions of participants from Division 1 will be tested later
Let's divide all trucks into the classes by l + r + c. It can be seen, that all the trucks that can be included in the answer are in the same class.
Let's solve the problem separately for each class. Consider all trucks from same class in the order they appear, and keep the following value: z[k] = the maximum sum that you can get, if the last taken truck has ri = k. Consider the truck number i - there are 2 options to update z:
It can update z[ri] with z[ri + ci] + vi, i. e. continue the motorcade, which has last truck with r = ri + ci. (For neighboring trucks should be true the following: rprev = ri + ci)
If li = 0, it can update z[ri] with vi, i. e. became the first truck in the new motorcade. (For the first truck should be true the following: li = 0)
The answer will be in z[0].
To restore the trucks included in the answer, we can keep with the maximal sum in z the index of last truck that updated this sum. Also we store the ancestor p for each truck that updated something in z. This ancestor is calculated when we consider i-th truck and doesn't change further: p[i] = -1 if truck i became beginning of the motorcade, otherwise p[i] = last truck that updated z[ri + ci].
We start restore of the answer from last truck updated z[0]. After that we restore everything using only p.
Welcome to Codeforces Beta Round #25 (Div. 2)
Authors of today's round problems are Mike Mirzayanov and me. I want to thank to Dmitry Levshunov for technical assistance in organizing the contest, as well as Gerald Agapov and Nikolay Kuznetsov for writing alternative solutions.
I wish you all good luck!
UPD: The contest is over, thank you to everyone for participating.
- Problems
- Standings
- Winner: marek.cygan
Welcome all to Codeforces Beta Round #22
Note that at this time registration is possible during the round. The contest will begin at 19:00 MSK.
Today I am an author of the problems. I would like to thank Mike Mirzayanov for help in contest preparations, Edvard Davtyan and Nickolay Kuznetsov for writing the verification solutions, and Julia Satushina for translating statements into English.
Good luck on the contest!
UPD: The contest is over. Thank you all for participating!
Problems
Results
Winner Kasparyanm_Mihail gains +203 to rating after the contest!
Welcome to Codeforces Beta Round #18
Authors of today's contest are Mike Mirzayanov, Edvard Davtyan and me. Thanks to Dmitry Matov for his help in statements preparation and Julia Satushina for translation of problems in English.
Good luck everyone!
- Problems
- Final standings
- Contest winner: I_am_Feeling_Lucky
Good afternoon.
Today I am the author of problems. I want to thank the creator of Codeforces Mike Mirzayanov and Edvard Davtyan for assistance in the problems preparation and Julia Satushina for great translations into English.
I wish everyone advance to the first division!
Artem Rakhov
UPD: The contest is over, thank you all for participating!
- Problems
- Final standings
- Contest winner: krijgertje







