Hello!
I am glad to invite you to participate in Codeforces Beta Round #57 (Div. 2).
Today's Contest was prepared by Amir Goharshady and Me.
We are thankful to Mike Mirzayanov , Artem Rakhov , Gerald Agapov , Mohammad Javad Naderi , Saeed Ilchi and Maria Belova.
Today's contest is dedicated to Khaje Nasir Tusi (Great Persian mathematician) since today is the national day of engineering in Iran.
![](https://upload.wikimedia.org/wikipedia/commons/b/b6/Al-Tusi_Nasir.jpeg)
Today for the first time in Codeforces we have Persian statements available for download.
You can download PDF version of statement from this link when the contest starts:
Persian
Have a good contest.
Alireza Farhadi and Amir Goharshady
I am glad to invite you to participate in Codeforces Beta Round #57 (Div. 2).
Today's Contest was prepared by Amir Goharshady and Me.
We are thankful to Mike Mirzayanov , Artem Rakhov , Gerald Agapov , Mohammad Javad Naderi , Saeed Ilchi and Maria Belova.
Today's contest is dedicated to Khaje Nasir Tusi (Great Persian mathematician) since today is the national day of engineering in Iran.
![](https://upload.wikimedia.org/wikipedia/commons/b/b6/Al-Tusi_Nasir.jpeg)
You can download PDF version of statement from this link when the contest starts:
Persian
Have a good contest.
Alireza Farhadi and Amir Goharshady
از همه شما متشکریم
Edit: It has become 15 minutes. I am not able to upload . What is the problem?
تو سوال دوم چرا
test case 4 (Ira__Persiann__Wonderful)
غلطه ؟؟؟؟؟
لطفا زود تر جواب بدید !
like.
ولی سخت بود !
Is it Persian? :)
I hope good luck all friends.
از دوستان ایرانی هم تشکر دمتون گرم
واقعا تو این اوضاع خیلی خوب امدید این کارو.
:D
Please Help!
The contest was awesome! Except for problem C!! Hope to see more Iranian contests!
How many numbers aj are there to the right of i such that ai > aj? To answer this question you should maintain a binary indexed tree / segment tree or a similar data structure: go from right to left, calculate the answer for ai and add ai to the tree.
Having done this, notice that the problem is pretty much the same for triples: the number of pairs aj, ak to the right of i is equal to the sum of the answers to the previous problem for all aj < ai, j > i.
For the second step, xj is either 0 or ans[j].
This requires two passes: one from left to right and one from right to left.
За ссылку спасибо. Предлагаю админам CodeForces ею воспользоваться :) . Но — если так сделать, будут ли эти мегабайты на стек всегда задействованы, то есть не будет ли необоснованных Memory Limit?
why?
"I think was lucky... I wish I won't need this lucky for the next contests =)"
(I just saying because I think is discouraging the same solution gives TLE and ACC xD)
It has very good design (thanks a lot!).
Plz put persian translate of every problem in every future contest too.
Thnx.
If any one have time plz tell...why the difference in output ?
http://ideone.com/GSqVs
Here it gives 3. and there at ideone it gives 7.
This was Q4.
maxx = vec[s][i].second;
change this visited = vector<int> (n ,0);
to visited = vector<int> (n + 1,0);