fcspartakm's blog

By fcspartakm, 9 years ago, translation, In English

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 (danilka.pro) 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.

  • Vote: I like it
  • +294
  • Vote: I do not like it

| Write comment?
»
9 years ago, # |
  Vote: I like it +6 Vote: I do not like it

We like your problems a lot, hoping for some more nice problems

»
9 years ago, # |
  Vote: I like it +7 Vote: I do not like it

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.

»
9 years ago, # |
  Vote: I like it -27 Vote: I do not like it

»
9 years ago, # |
  Vote: I like it -13 Vote: I do not like it

Why this contest starts in the unusual time???

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Will it be another dynamic scoring contest? I guess so.

»
9 years ago, # |
Rev. 2   Vote: I like it +25 Vote: I do not like it

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.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    you can ignore the character's name

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it -11 Vote: I do not like it

      Surely , but you will agree that it is annoying .

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it +29 Vote: I do not like it

        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 .

        • »
          »
          »
          »
          »
          9 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          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.

          • »
            »
            »
            »
            »
            »
            9 years ago, # ^ |
              Vote: I like it +8 Vote: I do not like it

            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.

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    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.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    Matryoshka is a real thing... I think all the "weird" names are real, maybe they are just not common in your country.

»
9 years ago, # |
  Vote: I like it +9 Vote: I do not like it

Yout last round was awesome. Especially the problem Round 297 B with a weak pretests.

»
9 years ago, # |
  Vote: I like it +27 Vote: I do not like it

return of the unrated's

»
9 years ago, # |
  Vote: I like it -71 Vote: I do not like it

Hope to see harder and of course more balanced problems than your last contests :D

  • »
    »
    9 years ago, # ^ |
    Rev. 2   Vote: I like it +19 Vote: I do not like it

    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

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +9 Vote: I do not like it

      just ignore him :)

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +15 Vote: I do not like it

      Very bad ( Why not simply sorry_silver_soul .

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      Actually, in Persian swear means more like "قسم". His name is a curse, a bad word (sexually). It mean f**k you in the ass.

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Actually, one of the meanings of swear is curse :)

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +20 Vote: I do not like it

    OK, guy. I'll try to do it!

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    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

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +25 Vote: I do not like it

    Surely div1 user

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

i am newly in this website,can anyone tell me how to practice before contest??

»
9 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Please try to minimize the description of problems statements. Although your problems are interesting, they are too long for non native English speakers

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Wish u happy coding;)

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

»
9 years ago, # |
  Vote: I like it -17 Vote: I do not like it

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.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Not all muslims live in your timezone. This kind of generalization is stupid. I'm a muslim, and this time is better for me.

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it -23 Vote: I do not like it

      if the time delays it doesn't make any problem for you but that solve a problem for me!

      • »
        »
        »
        »
        9 years ago, # ^ |
        Rev. 2   Vote: I like it +4 Vote: I do not like it

        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.

        • »
          »
          »
          »
          »
          9 years ago, # ^ |
            Vote: I like it -13 Vote: I do not like it

          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!

          • »
            »
            »
            »
            »
            »
            9 years ago, # ^ |
            Rev. 4   Vote: I like it 0 Vote: I do not like it

            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.

            • »
              »
              »
              »
              »
              »
              »
              9 years ago, # ^ |
                Vote: I like it -6 Vote: I do not like it

              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" ;)

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it -17 Vote: I do not like it

      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!

      • »
        »
        »
        »
        9 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        You didn't say most of muslims. You said muslims. And that statement implies what I said.

        • »
          »
          »
          »
          »
          9 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          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!

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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 ?

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Congrats unrated ones! One of you will probably win this thing (

»
9 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

usual time or unusual time This is a Question!!!

»
9 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Standard scoring!! Awesome.

»
9 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Have a nice contest,bless all!

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

May the God fold comments over 5 indent levels...

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

good luck and have fun guys :D

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

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)

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Ooops, it started 1.5 hours early than usual :)

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

I feel as if the author mistook the round as Div 1. Just saying

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

How to solve problem C?

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    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).

  • »
    »
    9 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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 heap

    Implementation: Link

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Did anyone else write binary search for B? I used 500 iterations and I wonder if it will pass...

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I was stuck counting quadrilaterals in D. Can anyone give me a hint?

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What was the solution for Div 2 C? I couldn't figure it out

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    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<L with less cost until you have a stable table. I think that can be implemented with a priority_queue.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    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.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Submitted a previous round's A problem by accident.. sigh. On the bright side, solutions are already up, wow!

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Same thing happened to me... I was very surprised when the judge told me my solution had exceeded the memory limit.

»
9 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Good contest with good scoring distribution , nice and understandable problems .

»
9 years ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

It is my first time to receive a message "thanks for hack" in a round. It feels very good!

@Cyber Thank you, too.

»
9 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

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) :)

»
9 years ago, # |
  Vote: I like it +2 Vote: I do not like it

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!

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Really challenging round, thanks ;)

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    а на чем можно было взломать А?

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      По-моему, как и все задачи, только на криворукости или невнимательности конкретного участника.

      UPD: А нет, я не прав, B и C попадали на тестах у большого числа участников.

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Я взломал именно неправильное решение по В на тесте
        3 18
        1 1 1 1 1 5
        ребята работали с max и min...

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Да там у парня опечатка была — он жадно пытался увеличить количество дипломов первой степени до максимального количества дипломов второй степени.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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 ?

»
9 years ago, # |
  Vote: I like it +13 Vote: I do not like it

To all cout lovers: Wrong answer is in coming! :(

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

I forgot to use "setprecision" on B using cout. Nice!!!!

»
9 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

I am feeling very very sad. Just used cout instead of scanf and got wa on test 32 :(

»
9 years ago, # |
  Vote: I like it +11 Vote: I do not like it

very nice contest (specially problem D ) but I hate working with doubles :\

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Anyone else fail B because of precision error?

  • »
    »
    9 years ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

    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

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      but 1e-6 error should be accepted, isn't it?

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        If you used cout, your error on test 32 is 4.7*(1e-6), which is greater than 1e-6. Hence, the solution failed.

»
9 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

First i used this :

cout<<ans; (ans is of type long double) I got wrong answer.

Then i changed it to :

printf("%lf",(double)ans); Got AC.

Double and long double have precision upto 6 digits.So, printf gave AC. But , what is the problem with cout?

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
9 years ago, # |
Rev. 2   Vote: I like it +12 Vote: I do not like it

use printf instead of cout for better precision or use setprecision with cout

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

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

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Add cout.precision(10);

    Here is your AC code: 11868422

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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?

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I got the reason. Cout apparently has lower precision by default. Didn't realize this during the contest. Thanks!

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    rather going for binary search apply little math and answer is just 2 line code

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      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.

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        • »
          »
          »
          »
          »
          9 years ago, # ^ |
            Vote: I like it +3 Vote: I do not like it

          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.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    cout<<fixed<<setprecision(10);
    
»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

can anyone tell me why my submission getting TLE ..ON Nlog(N) time complexity in problem B my solution is #include<bits/stdc++.h> 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<<m; return 0; }

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    first of all,add your source in a pastebin,else none will read it like that. secondly,set precision. (cout.precision(10) for example)

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi guys, can someone suggest where i might haved made a mistake in this submission http://codeforces.com/contest/557/submission/11868290 Thanks

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    1. 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
    2. Once you read in the data, you have to sort the array because binary search only works on monotonous intervals
    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Scanner is slow. It's better to parse the input, but you don't need to write it every time.

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

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?!

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Ratings up

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

»
9 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Finally Division 1!!!

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

My solutions were skipped! Why!!!

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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)

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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.

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I did not copy anyone's code. Next time I'll remember to set my ideone submissions to private.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    improve i/o 11870141

    add ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

http://codeforces.com/contest/557/submission/11870535

Getting 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.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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/11870567

The idea is basically the same as the author:

  1. Precalculate cost of removing all legs of larger size
  2. Iterate over each leg size, removing larger ones in O(1)
  3. Keep a Priority Queue with the legs of lower size to obtain the largest ones in lg(n)
  4. 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)
  5. Minimum Energy Used = min(currentMin, energy of larger + energy of lower — energy of non-removed legs

Thank you very much in advance!

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Did anyone get AC in B using binary search??

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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).