### fcspartakm's blog

By fcspartakm, 5 years ago, translation, ,

Hello, Codeforces!

I'd like to invite you to Codeforces Round #311 (Div. 2). It'll be held on Tuesday, June 30 at 18:00 MSK and as usual Div. 1 participants can join out of competition. Note that round starts in the unusual time!

Great thanks to Maxim Akhmedov (Zlobober) for helping me preparing the contest, to Maria Belova (Delinur) for translating the statements into English, to Mike Mirzayanov (MikeMirzayanov) for the great Polygon platform and ideas of some problems and to my friends Ilya Los (IlyaLos) and Danil Sagunov (dans) for writing solutions.

The scoring distribution will be announced later. Good luck everyone!

UPD The scoring distribution will be standard today 500-1000-1500-2000-2500.

UPD2 Competition completed! Thank you all!

UPD3 You can find editorial here.

• +294

 » 5 years ago, # |   +6 We like your problems a lot, hoping for some more nice problems
 » 5 years ago, # |   +7 Hoping that the problems' difficulty will be contantly increasing(like they were in your last round #297) not something like first two problems are extremely easy and the third a lot harder.
 » 5 years ago, # |   -27
 » 5 years ago, # |   -13 Why this contest starts in the unusual time???
 » 5 years ago, # |   0 Will it be another dynamic scoring contest? I guess so.
•  » » 5 years ago, # ^ |   +4 Your guess was wrong.
 » 5 years ago, # | ← Rev. 2 →   +25 Just one request , please make the problem statements clear and don't name the characters something like "**matryoshka**" . Its very annoying when you are not sure of the problem statement and on top of that the characters have such unpronounceable names.
•  » » 5 years ago, # ^ |   +4 you can ignore the character's name
•  » » » 5 years ago, # ^ |   -11 Surely , but you will agree that it is annoying .
•  » » » » 5 years ago, # ^ |   +29 yes but sometimes they use some weird words or names to confuse you and actually they're not part of the problem and u should focus on the main idea .
•  » » » » » 5 years ago, # ^ |   0 Its your point of view , personally i believe that a good problem should give the participant a hard time in figuring out the solution not in figuring out what the problem actually wants from us.
•  » » » » » » 5 years ago, # ^ |   +8 i have taken part in 5 regional contests and 6 or more other onsite contests in the past 3 years and I've seen a lot of problems which had weird names or even they explain something that just a story for fun and they're not part of main problem so after u see them you just ignore them . you know , they're just part of the contest not important.
•  » » » 5 years ago, # ^ |   0 The story is not irrelevant as it gives us a real life problem. But one should keep it in mind to not let the story make the problem confusing. People has to read all of the statement and a big story with complicated characters and stuffs can mess up a contestant's head.
•  » » 5 years ago, # ^ |   +1 I don't agree. As a programmer you must be able to convert "real" problem (with legend, weird names and everything) to math/coding one. That's just IMHO, but as for me — legend is a good part of problem.
•  » » » 5 years ago, # ^ |   0 I'm not saying that i have problem with the weird names used in contests . I'm trying to say that the problem statement shouldn't be confusing like 310 div1-A or "Haar Feathers" .If the problem statements are vague , participants have a hard time coding the solution and the situation is made further miserable if the name of the characters are complicated . In that case , it becomes difficult to maintain ones patience while reading the problem 2 or more times . Again , it varies from person to person and it is just how i feel .
•  » » 5 years ago, # ^ |   +2 Matryoshka is a real thing... I think all the "weird" names are real, maybe they are just not common in your country.
 » 5 years ago, # |   +9 Yout last round was awesome. Especially the problem Round 297 B with a weak pretests.
•  » » 5 years ago, # ^ |   0 Yeah !
 » 5 years ago, # |   +27 return of the unrated's
 » 5 years ago, # |   -71 Hope to see harder and of course more balanced problems than your last contests :D
•  » » 5 years ago, # ^ | ← Rev. 2 →   +19 who the hell are you? :| what did i do to you? what made you do such a retarded thing? guys in our language this guys handle name is a swear and his name is "arash mahmoodian" strange thing though what a small universe it is when you can find someone with the same name and same organization
•  » » » 5 years ago, # ^ |   +9 just ignore him :)
•  » » » 5 years ago, # ^ |   +15 Very bad ( Why not simply sorry_silver_soul .
•  » » » 5 years ago, # ^ |   +11 Actually, in Persian swear means more like "قسم". His name is a curse, a bad word (sexually). It mean f**k you in the ass.
•  » » » » 5 years ago, # ^ |   0 Actually, one of the meanings of swear is curse :)
•  » » » » 5 years ago, # ^ |   0 calm down Prince. :P You are Red now so keep calm and keep coding. ;)
•  » » 5 years ago, # ^ |   +20 OK, guy. I'll try to do it!
•  » » 5 years ago, # ^ |   +10 nice at least you changed your name don't make shitty account like this anymore of course this was just a suggestion i don't give a damn or two about you
•  » » 5 years ago, # ^ |   +25 Surely div1 user
 » 5 years ago, # |   0 hope that there wont be any users with fake id's :)
 » 5 years ago, # |   0 Have Nice Contest :D
 » 5 years ago, # |   0 i am newly in this website,can anyone tell me how to practice before contest??
•  » » 5 years ago, # ^ |   0
•  » » 5 years ago, # ^ |   +8 and don't forget to check your username in registrants list just before the contest , good luck !
•  » » 5 years ago, # ^ |   +16 nowdays i kind of doubt every unrated user
•  » » » 5 years ago, # ^ | ← Rev. 2 →   -6 Me too, except for sorry_dreamoon first appearance.
 » 5 years ago, # |   +2 Please try to minimize the description of problems statements. Although your problems are interesting, they are too long for non native English speakers
 » 5 years ago, # |   +3 Wish u happy coding;)
 » 5 years ago, # |   0 I have a problem, I can't submit my solution today.it's getting "Network error" when after I submit my solution.any advice?thanks.
•  » » 5 years ago, # ^ |   0 Try to remove cache of your browser then try again
•  » » » 5 years ago, # ^ |   0 already tried.but it's still same.I can't submit my solution. :(
 » 5 years ago, # |   -23 I will win this round. ;)
 » 5 years ago, # |   -17 hello to all. i think for muslims that they're rozeh* , they cannot take contest well!! please delay the contest for 2 hours.rozeh: it means that you don't eat and drink from morning(sunrise) to night(sunset). it's a necessary for muslims!thanks to all.
•  » » 5 years ago, # ^ |   +6 Not all muslims live in your timezone. This kind of generalization is stupid. I'm a muslim, and this time is better for me.
•  » » » 5 years ago, # ^ |   -23 if the time delays it doesn't make any problem for you but that solve a problem for me!
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +4 You're wrong. It makes problem for me. My iftar gets in the middle of the contest. But I never whined like you because I know that this issue is relevant for small minority. Current time change benefits every muslim user from Turkey. Of course, you can say that number of users from Iran is greater than Turkey, but if we think that way, number of muslim users is less than others. They can't arrange a round according to minority. It's impossible to make everyone happy. If time is not suitable for you, you can always virtually participate.
•  » » » » » 5 years ago, # ^ |   -13 No. if it delays for just 1:15 hour it doesn't make any problem for not muslims users!! but it solve a problem for most of the muslims!
•  » » » » » » 5 years ago, # ^ | ← Rev. 4 →   0 You said it doesn't make any problem for you, and I simply explained why it makes a problem for me. And now you're saying "No. if it delays for just 1:15 hour it doesn't make any problem for not muslims users!!" I kindly want to remind you that I'm a muslim, and I already stated that in my first post. I already answered why it's a bad idea to want them to change time, that's why I'm gonna stop answering. I think you reply even before reading my answer.Btw, how do you know that it doesn't make any difference for all other users? Do you know all of them? Do you know their schedules or their plans? Everybody has their problems, but it's just you who complains.
•  » » » » » » » 5 years ago, # ^ |   -6 what are you saying?i reply that comment for this part of you comment!" Of course, you can say that number of users from Iran is greater than Turkey, but if we think that way, number of muslim users is less than others. They can't arrange a round according to minority" ;)
•  » » » 5 years ago, # ^ |   -17 there are more that 200 million muslims in my time zone or near to me. but because you are near to europe musllims are not a lot!. note that all of Turkiye people are not muslim! i think understanding this that i spoke about all of muslims is more stupid!! i spoke about most of muslims!
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   0 You didn't say most of muslims. You said muslims. And that statement implies what I said.
•  » » » » » 5 years ago, # ^ |   0 i'm sorry because the argue but it's important never comment doesn't make any sense!if my comment get 1000 likes there would n't be any time changing!thank for thinking about my comments!
•  » » 5 years ago, # ^ |   -13 I'm not muslim but i think this is a very valid reason.CF should delay contest if possible.
 » 5 years ago, # |   0 The last codeforces round was the first time I tried to hack people , but the problem was that I couldn't highlight the code ( to copy-paste it in my computer) is this made by purpose ?
 » 5 years ago, # |   +1 Congrats unrated ones! One of you will probably win this thing (
 » 5 years ago, # | ← Rev. 2 →   +1 usual time or unusual time This is a Question!!!
•  » » 5 years ago, # ^ |   0 previous contests held in 19:30 MSK (21:00 Tehran)
 » 5 years ago, # |   +6 Standard scoring!! Awesome.
 » 5 years ago, # |   +2 Have a nice contest,bless all!
 » 5 years ago, # |   0 May the God fold comments over 5 indent levels...
 » 5 years ago, # |   +1 good luck and have fun guys :D
 » 5 years ago, # |   +3 Well, I read some comments... and I was like WTF? Whats goin on here... ?? M never ever gonna read comments on CF #Round Invitation. (Period)
 » 5 years ago, # |   0 Ooops, it started 1.5 hours early than usual :)
•  » » 5 years ago, # ^ |   0 Get Coder's calendar plugin maybe ? :D
 » 5 years ago, # |   0 What the hell I am not understanding the sample test 3 of problem C how the output could be 8??? Please Explain
•  » » 5 years ago, # ^ |   0 Sorry I got it now
 » 5 years ago, # |   +1 I feel as if the author mistook the round as Div 1. Just saying
 » 5 years ago, # |   +3 How to solve problem C?
•  » » 5 years ago, # ^ |   +1 I'm not sure if my approach is totally correct. My algorithm is somehow greedy, I try to make each possible leg length the maximum one. In order to do this, you need to remove all the legs with a greater length than the current one. Then, for this new configuration valid, you could only have 2 times the amount of the legs of the current length — 1, to satisfy the problem requirements. So greedily, you have to keep in this new configuration the legs that cost the most to be removed and are shorter than the current one and take out the remaining ones (pay for them to be removed).
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 First you choose your max value , after that you can see the next observations : it is better to take the most quantity of elements with this max value. the values greater than max value are not considered the values lesser than max value are considered Let F = frecuency of the fixed max value then you can choose at most F — 1 of this lesser values , you choose the better F — 1.If you sort like pairs , you can build a simple algorithm with an heapImplementation: Link
 » 5 years ago, # |   +1 Did anyone else write binary search for B? I used 500 iterations and I wonder if it will pass...
•  » » 5 years ago, # ^ |   +1 I tried using Binary Search too. I could not get it to pass correctly though :) will upsolve.
•  » » » 5 years ago, # ^ |   0 I ended up getting AC with 500 iterations :D
•  » » » » 5 years ago, # ^ |   0 link to solution?
•  » » » » » 5 years ago, # ^ | ← Rev. 2 →   0
•  » » 5 years ago, # ^ |   0
 » 5 years ago, # |   0 I was stuck counting quadrilaterals in D. Can anyone give me a hint?
•  » » 5 years ago, # ^ |   0 One word hint: Bipartiteness
•  » » » 5 years ago, # ^ |   0 '□' Love it, Thanks!!
•  » » » » 5 years ago, # ^ |   0 think in bicoloring
 » 5 years ago, # |   0 What was the solution for Div 2 C? I couldn't figure it out
•  » » 5 years ago, # ^ |   +1 I think it was greedy: search for all lengths L what is the cost to produce a stable table with L as the max length. Fixed L, you should remove all the legs with length>L; if now is stable compute the cost, otherwise start removing legs with length
•  » » 5 years ago, # ^ |   +1 My solution is as follows: Let's say we want to 'select' legs. You have to maximize the sum of energy of selected legs. For every length l, consider it is the maximum. We would have selected a certain amount of legs with length l, let's say x. Then we can select (x-1) legs (at most) that are shorter than l. Those (x-1) legs should be maximum in energy.Because the d limit is quite small, you can look from 200 to 1, select no more than x legs that are shorter than l. So you just have to sort the legs by length and count.
•  » » 5 years ago, # ^ |   0 There is only one div in this occation. So the specification is not needed. The primary reason I post here is so that I can read when someone explains how to solve the problem though.
 » 5 years ago, # |   +1 Submitted a previous round's A problem by accident.. sigh. On the bright side, solutions are already up, wow!
•  » » 5 years ago, # ^ |   0 Same thing happened to me... I was very surprised when the judge told me my solution had exceeded the memory limit.
 » 5 years ago, # | ← Rev. 2 →   +1 Good contest with good scoring distribution , nice and understandable problems .
 » 5 years ago, # | ← Rev. 2 →   +6 It is my first time to receive a message "thanks for hack" in a round. It feels very good!@Cyber Thank you, too.
 » 5 years ago, # | ← Rev. 2 →   +5 Thanks for an interesting problemset. But it would be even more interesting in case there were more possibilities for challenges :)Upd. Oh, I was wrong, in fact there were quite a lot of solutions to hack (especially B's with wrong output format) :)
 » 5 years ago, # |   +2 I've been training a lot and level C problems are starting to look as hard as Level B problems did for me about 2 months ago. Progress feels great! Thanks for the problems!
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 whT did u do ?
 » 5 years ago, # |   0 Really challenging round, thanks ;)
•  » » 5 years ago, # ^ |   0 а на чем можно было взломать А?
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 По-моему, как и все задачи, только на криворукости или невнимательности конкретного участника.UPD: А нет, я не прав, B и C попадали на тестах у большого числа участников.
•  » » » » 5 years ago, # ^ |   0 Я взломал именно неправильное решение по В на тесте3 181 1 1 1 1 5ребята работали с max и min...
•  » » » 5 years ago, # ^ |   0 Да там у парня опечатка была — он жадно пытался увеличить количество дипломов первой степени до максимального количества дипломов второй степени.
 » 5 years ago, # |   0 for B isn't answer min(w , 3.0*n*min(arr[0],arr[n]/2.0)) on sorted array ? Or Is binary search the only way to go ?
•  » » 5 years ago, # ^ |   +3 Answered my own question, it is, mine got AC.
 » 5 years ago, # |   +13 To all cout lovers: Wrong answer is in coming! :(
 » 5 years ago, # |   +1 I forgot to use "setprecision" on B using cout. Nice!!!!
 » 5 years ago, # | ← Rev. 2 →   +1 I am feeling very very sad. Just used cout instead of scanf and got wa on test 32 :(
 » 5 years ago, # |   +11 very nice contest (specially problem D ) but I hate working with doubles :\
 » 5 years ago, # |   +3 Anyone else fail B because of precision error?
•  » » 5 years ago, # ^ | ← Rev. 2 →   +1 Of course... me, you and a couple hundreds more.. used 1e-9 for binary search and printed exactly 6 digits.. got acc after round only after using 1e-11 and printed 8digits
•  » » » 5 years ago, # ^ |   0 but 1e-6 error should be accepted, isn't it?
•  » » » » 5 years ago, # ^ |   0 If you used cout, your error on test 32 is 4.7*(1e-6), which is greater than 1e-6. Hence, the solution failed.
 » 5 years ago, # | ← Rev. 2 →   +1 First i used this :cout<
•  » » 5 years ago, # ^ | ← Rev. 2 →   +1 You have to use cout << fixed << setprecision(6) << ans. See http://www.cplusplus.com/reference/iomanip/setprecision/EDIT: I think it's setprecision(6), in the actual contest I used setprecision(9) to be safe, and it got AC.
•  » » 5 years ago, # ^ |   0 You can also use the following line before printing the answer using cout.cout.precision(10); cout<
 » 5 years ago, # |   0 can anyone please explain why using %0.9lf with printf gives TLE on pretext 8 while %0.7lf passes in 1/10th time.(second last line) passed solution with %0.7lf — 11862093. TLED solution with %0.9lf — 11861535
 » 5 years ago, # | ← Rev. 2 →   +12 use printf instead of cout for better precision or use setprecision with cout
•  » » 5 years ago, # ^ |   0 king_of_hackers? Probably.king_of_memes? Yeah ;)
 » 5 years ago, # |   +3 I am not able to figure out what could be wrong with my code for problem B. Could someone help me track the error in this submission?11859368
•  » » 5 years ago, # ^ |   0 Add cout.precision(10);Here is your AC code: 11868422
•  » » » 5 years ago, # ^ |   0 Hi, thanks for your prompt reply! Could you provide a bit insight as to why this was required, and why not using this gave me a wrong answer?
•  » » » 5 years ago, # ^ |   0 I got the reason. Cout apparently has lower precision by default. Didn't realize this during the contest. Thanks!
•  » » 5 years ago, # ^ |   0 Its all about precision, use printf("%lld")
•  » » 5 years ago, # ^ |   +2 rather going for binary search apply little math and answer is just 2 line code
•  » » » 5 years ago, # ^ |   +3 Have a look again man. I used it at first, but then removed it. The function is still there, but it is not being called anywhere.
•  » » » » 5 years ago, # ^ |   0 Have a look at my submission http://codeforces.com/contest/557/submission/11867954
•  » » » » » 5 years ago, # ^ |   +3 I think you did not want to look at the submission and go through the logic before commenting this. Just to let you know, I have figured out the error, thanks to minimario. The error was not in the logic, but in the precision. I did not know that the precision of cout by default was less than 10, and so, didn't realize that it should be explicitly changed.Giving a link to your own submission is the least helpful way when someone asks why his code doesn't work.
•  » » 5 years ago, # ^ |   0 cout<
 » 5 years ago, # |   0 DIV2 ProbB — My solution came wrong just bcz I did not use set precision :( .If possible can anyone explain how set precision is helping in getting the problem accepted.
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 It is asked from the problem statement. It says that needs to be relative to 10^-6.
 » 5 years ago, # |   0 can anyone tell me why my submission getting TLE ..ON Nlog(N) time complexity in problem B my solution is #include using namespace std; long double Ar[200005]; int main(){ long double n1,m,w,k,mn,mx,x; long long int n,i; cin>>n>>w; n1=n; for(i=0;i<(2*n);i++)cin>>Ar[i]; sort(Ar,Ar+(2*n)); mn=min(Ar[0],(Ar[n]/2)); x=w/(3*n1); x=min(x,mn); m=(3*n1*x); cout<
•  » » 5 years ago, # ^ |   0 first of all,add your source in a pastebin,else none will read it like that. secondly,set precision. (cout.precision(10) for example)
•  » » » 5 years ago, # ^ |   0 [submission:11856599]of [problem:557B] now can u solve my problem i m not asking about precision i m asking about time complexity
 » 5 years ago, # |   0 Hi guys, can someone suggest where i might haved made a mistake in this submission http://codeforces.com/contest/557/submission/11868290 Thanks
•  » » 5 years ago, # ^ |   0 Use scanner and System.out.println, as they are much faster to type(You can use a macro for System.out.println) and less prone to errors Once you read in the data, you have to sort the array because binary search only works on monotonous intervals
•  » » » 5 years ago, # ^ |   0 Scanner is slow. It's better to parse the input, but you don't need to write it every time.
 » 5 years ago, # |   +3 Has anyone else notice that ios_base::sync_with_stdio(0);cin.tie(0); is not working(almost) anymore in CF? I've seen cin,cout is slower in CF comparing to other judges. But this much? My B was a narrow escape. using scanf 155 ms using cin 904 ms Is this because of some recent changes in system or it was always like this and i never noticed?!
•  » » 5 years ago, # ^ |   0 I had a similar problem, so I added cout.tie(0);, and it runs a bit faster. But to my experience scanf/printf are much faster than cion/cout even after that.
•  » » 5 years ago, # ^ |   +3 it's just iostream for double is very slow even after using ios_base::sync_with_stdio(0);cin.tie(0);. see link : http://codeforces.com/blog/entry/5217
•  » » » 5 years ago, # ^ |   0 You are right. My code runs as expected after taking input as int array instead of double. Thanks. Learned sth new :)
•  » » » 5 years ago, # ^ |   0 I use only int and scanf is more than 50% faster: http://codeforces.com/contest/557/submission/11856815 http://codeforces.com/contest/557/submission/11871020
 » 5 years ago, # |   0 Any one can help to find out what is wrong with my program? I got a wrong answer a large input but I run the same input in my computer it is ok.The problem seems to be overflow on something but I cannot find it out.11854334
•  » » 5 years ago, # ^ |   0 u need to edit here not typecasted to double ans = (double)a[0]*3*n
•  » » 5 years ago, # ^ |   0 your ac solution , declare w as a double 11869049
•  » » » 5 years ago, # ^ |   0 Thanks very much! But I still don't get it why my version is wrong .... And I get another wrong answer with only declaring w as double 11869173
 » 5 years ago, # |   0 Ratings up
 » 5 years ago, # |   0 My idea for C was the following.Sort the current legs and group the following quantities about each leg: frequency, cost.Either we include the current leg or not. If we don't include it, we HAVE to delete it. Add the cost. Otherwise the lower legs will not be maximum. If we include it, in the remaining lower legs, we have to find the minimum possible cost which will make the length of the current leg maximum. If the frequency for the current leg is f, and if we have a total of t lower legs, we need to delete t - (2·f - 1) legs with minimal cost. This can be done efficiently as the values of the costs are 1 ≤ x ≤ 200.
 » 5 years ago, # |   0 So I originally misread problem B, and missed the fact that all of the boys had to have the same amount, and all of the girls had to have the same amount in their cups. If we removed this restriction, what would be the solution to the problem then? Is it NP complete or is there some algo? Any insight would be appreciated.
 » 5 years ago, # |   +6 Finally Division 1!!!
 » 5 years ago, # |   0 My solutions were skipped! Why!!!
•  » » 5 years ago, # ^ |   0 This was because the exact solutions you submitted were already submitted by someone else. So either your luck is really bad(2 skipped problems), or you copied someone else's codes.
•  » » » 5 years ago, # ^ |   0 Not so bad luck! One of those solutions gave wrong answer....so whichever poor guy's solution matched is the unlucky one(probably, assuming he didn't change his code because the pretests were passed)
•  » » » » 5 years ago, # ^ |   0 If someone's solution gets skipped, then this means their solutions matched before system testing as well. Why can't the system detect this and give skipped verdict instead of pretests passed? Even the biggest cheaters would tweak their copied codes a little so it doesn't get skipped. The only people who get affected are innocent (imo) because they had no idea their coding style is so obvious (Do something about this Mike. On some other day, I'd be really sad if this happened.
•  » » » 5 years ago, # ^ |   0 I did not copy anyone's code. Next time I'll remember to set my ideone submissions to private.
 » 5 years ago, # |   0 getting tle on 2nd question for 8th test case .. can anyone please tell what should i change in my code to get accepted ..here is the solution link http://codeforces.com/contest/557/submission/11869859
•  » » 5 years ago, # ^ |   0 improve i/o 11870141add ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
•  » » » 5 years ago, # ^ |   0 could you also have a look at these solutions i just changed %.9lf to %.7lf in printf and got AC accepted with %0.7lf ----- 11862093 TLE with %0.9lf ----- 11861535 thanks.
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   0 use scanf instead of cin11870249
•  » » » » » 5 years ago, # ^ |   0 thanks!
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 i didnt change the i/o methods but my code is accepted after changing some unnecessary doubles to long long int's ..i think there is different execution time for double and long long int's.. here is the link of my edited code ... http://codeforces.com/contest/557/submission/11870272
•  » » 5 years ago, # ^ |   0 2nd problem is input intensive, so using cin stream slows down the code, and also std::vector is much slower than plain arrays, as vectors have to spend more time resizing...in such tasks you'll be better off using printf, scanf as well as bare boned data structures. u can also use ios_base::sync_with_stdio(false); in the beginning of your main function.
•  » » » 5 years ago, # ^ |   0 not bad, you just need to go faster :)
 » 5 years ago, # |   0 I did so bad, thought I'd go back to being pupil once again...Very surprised as my rating improved by 60 points.
 » 5 years ago, # |   0 http://codeforces.com/contest/557/submission/11870535Getting correct answer(2) on the first case on my computer but 0 on it on codeforces servers? This is the first time I'm submitting a solution in c++, so maybe I'm missing something.
 » 5 years ago, # |   0 Can someone, please, tell me what's wrong with my code for C? It gives the correct answer with all the small cases so I cannot debug it. At least some test case that won't pass with it.I wrote a lot of comments to make it easy to understand: http://codeforces.com/contest/557/submission/11870567The idea is basically the same as the author: Precalculate cost of removing all legs of larger size Iterate over each leg size, removing larger ones in O(1) Keep a Priority Queue with the legs of lower size to obtain the largest ones in lg(n) Obtain from the priority queue a number of legs strictly lower than the number of legs of the current size (which won't be deleted) Minimum Energy Used = min(currentMin, energy of larger + energy of lower — energy of non-removed legs Thank you very much in advance!
•  » » 5 years ago, # ^ |   +3 I've used similar idea. But couldn't find bug in your code. See if this helps
•  » » » 5 years ago, # ^ |   0 Thank you. I cannot find a single case that doesn't work with my code. I'm running many random cases against Accepted codes without any luck :(
•  » » » 5 years ago, # ^ |   +3 Finally, I found the problem with my code. It didn't have to do with the algorithm but with Java!The problem was in the way that Java compares Integer objects:Incorrect: if (legs[i].first != legs[i + 1].first) {Correct: if (legs[i].first.intValue() != legs[i + 1].first.intValue())Explanation: http://stackoverflow.com/a/1514919AC code (almost the same): http://codeforces.com/contest/557/submission/11873179
 » 5 years ago, # |   0
 » 5 years ago, # |   0 Did anyone get AC in B using binary search??
•  » » 5 years ago, # ^ |   +1 Seems like a dream if you do not set increment up to 1e-11 :p
•  » » 5 years ago, # ^ |   0 Me That's my code.Link
•  » » » 5 years ago, # ^ |   +3 Then you are one of the lucky ones
 » 5 years ago, # |   0 Problems are really interesting but statements are quite hard to understand. I've fun solving them but I think it will be better if you make the statement simple (IMO).
 » 5 years ago, # |   0 No new contests? :(