gepardo's blog

By gepardo, history, 3 years ago, translation, In English,

Hello, Codeforces!

Tomorrow, in November 15, 2016 at 19:35 MSK a regular Codeforces round for participants in the second division will be held. As usual, participants from the first division can take part out of competition.

I (alex256) am the author of the contest. It's my first round and I hope it won't be the last. Great thanks to Gleb Evstropov (GlebsHP) for help in preparing the contest, Andrey Kalendarov (Andreikkaa) for testing the round and Mike Mirzayanov (MikeMirzayanov) for the great platforms Codeforces and Polygon.

As usual, the participants will be given 6 problems and two hours to solve them. I recommend to read ALL the problems. I wish everyone many Accepted and, of course, enjoy solving the problems.

The problems will be about my younger brother Anton. I hope you'll like them :)

The round is rated.

UPD: Though, the round won't be completely usual and there will be 6 problems.

UPD2: The scoring is 500-750-1250-1500-2000-2750.

UPD3: Tutorial is available now.

UPD4: Contest is over, congrats to winners :)

Div. 2

  1. Xilya

  2. CisnijAsdPawel

  3. VemMonstro13

  4. fulvioabrahao

  5. Mehrdad_S

Div. 1

  1. sugim48

  2. uwi

  3. khadaev

  4. HellKitsune

  5. Um_nik

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

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

Finally a regular round!

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

    Let's hope for a great round with diverse problems!

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

Finally a usual 2 hour contest. All the best for your first contest as a problem setter alex256

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

Usual time? How unusual!

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

Here we go again :D

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

It is becoming so usual to see comments about usuality

»
3 years ago, # |
Rev. 4   Vote: I like it -10 Vote: I do not like it

It is such a long time that has no contest!

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

is it rated?

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

"I wish everyone many accepted" — yes! we love this green word.

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

I wonder why so little div 1 contest lately. So sad :(

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

Hope next contests will be a bit earlier.

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

I have recently joined.Shall I be able to participate in #379(Div.2) ?

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

    Of course yes, just register to the contest. Wish you good luck :)

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

I wanna thank your younger brother who faces problems and made us get into competition , All the greetings and appreciation to him

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

    Thank you, it is me.

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

      I hope you are not competing in this round, that would be a huge advantage against all other participants, as you already know all your problems

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

        No, of course, I'm fair. I know all the problems and I will not compete in this round.

        Good luck everyone! I hope you will enjoy this round!

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

It's happening after a long time, also after a long time next one will happen! we'll miss it for long time!

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

I'm attending a CF round after a long time hope there are a lot of interesting problems :)

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

    I also hope that my problems will be interesting for you :)

»
3 years ago, # |
  Vote: I like it -8 Vote: I do not like it

"the round won't be completely usual", will there be a clown dancing in the middle of the contest or something :D

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

6 problems in 2 hours, will they be enough??? or shouldn't it be at least 2:15 :\

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

come on !!!! 12 more days until the upcoming div1 round

»
3 years ago, # |
Rev. 2   Vote: I like it -8 Vote: I do not like it

It seems that not having 5 problems is the new default

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

I guess problem C hacks use this: ci are not decreasing and di are not decreasing?

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

    I hacked someone because he didn't handle only using second spell.

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

E test 3 — what was this?

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

    Consider a white node connected to three black nodes and each of these black nodes is connected to another white node. The answer is 2.

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

    in first sample , add a white child to 11 , that should fail most wrong logics.

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

    Maybe something like this?

    16
    1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1
    1 2
    1 3
    2 4
    2 5
    3 6
    3 7
    4 8
    4 9
    5 10
    5 11
    6 12
    6 13
    7 14
    7 15
    8 16
    

    Answer is 4.

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

    It was just a random test.

»
3 years ago, # |
  Vote: I like it -22 Vote: I do not like it

Is this rated?

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

How to solve C?

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

    using binary search!!

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

    Use binary search.Since potions of type 2 are already sorted and also greater the cost of potion 2 greater is the number of potions that are immediately completed. for each potion of type 1 find the maximum type 2 potion that can be bought using upper_bound(In C++ ofcourse) and find the amount of time it takes and find minimum among those.

    Time Complexity — mlogk

    m-number of potions of type 1 k-number of potions of type 2

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

      I used similar approach but failed on pretest 3... 22247888 any idea why its failing ?

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

        pretest 3 was about not considering using only first spell I think.

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

          in the commented portion i was tackling that as well but still It was failing on pretest 3. btw can we see pre tests once the contest is over ?

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

            yep, just scroll down to see tests.

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

        What if we just need to cast spell type 2?

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

    1.First solve for only using second type spell — O(k) 2.Iterate over m and during each iteration use binary search on k and find minimum value during each iteration. 3.Then take minimum of all value which find in step 2.

    Time complexity — O(mlogk)

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

      I add one artificial spell to both types. (x, 0) for the first type, and (0, 0) for the second one. Picking one of this spells is equivalent to taking none of respective types as they have no effect. Thus I was always picking exactly one first type and exactly one second type spell, sparing myself consideration of corner cases. It got accepted so I suppose it's valid.

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

    Two pointers. Sort first spells by mana and go from left to right, at each step decrease the pointer for the second spell while you don't have enough mana.

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

    I solved it with two pointer technique

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

    sort first type spell's by cost of each. then you can use Two Pointer algorithm for each a[i] (the i-th first type spell)

»
3 years ago, # |
Rev. 102   Vote: I like it 0 Vote: I do not like it

когда это редакционная?

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

Should have defined axis in D . The picture for sample 1 got me all confused :/

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

What is the simpsons prediction about this contest ?

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

Any approach for problem E? i used dp on trees but it failed on pretest 3. My solution

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

    compress adjacent node with same color , answer is radius of this tree.

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

      ohh nice one! but can you look into my dp solution? (its short and easy to understand). I cant figure out why its wrong.

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

        in the first sample add a white child to node 11 , answer is 2 , your code gives 3

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

      Why is the answer radius of the tree?

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

        pick the centre of the compressed tree , and keep painting it till the color reaches the leaves , it takes radius number of steps.

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

          How did you not think it was dp on a tree question?

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

        After painting one node (and compressing the tree again), the number of layers of the tree decreases at most by one, so we have to find a tree with the minimum number of layers (minimum depth). That means that the root must be the center of the tree

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

    The colors make a ring like structure visually. ans=no. of rings-1

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

Nice contest! Easy problems — so I can feel me smart xD

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

What was the hacking testcase for F? Probably something for which answer looks nice, but b[i] and c[i] are computed incorrectly.

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

I tried hacking this code on test case: 5000000 5000000 5000000 5000000

but got unsuccessful hacking attempt :( . I was expecting int overflow as the ans for this test case is

1280000000

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

Whats the fastest way to check for the optimal solution in C?

I checked for Spell 1 only and Spell 2 only by normal for-loop and used two-pointer method for Spell 1 + Spell 2 checking.

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

    Use binary search.Since potions of type 2 are already sorted and also greater the cost of potion 2 greater is the number of potions that are immediately completed. for each potion of type 1 find the maximum type 2 potion that can be bought using upper_bound(In C++ ofcourse) and find the amount of time it takes and find minimum among those. Time Complexity — mlogk m-number of potions of type 1 k-number of potions of type 2

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

      Oh damn, I'm an idiot. I thought that the upper_bound function was O(N).

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

At the last minute, I submitted D and got WA, and I found there was an obvious bug and fixed it immediately, there was 15 seconds left and I resubmitted as soon as I could, but I couldn't click the submit button T T

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

Can someone give me testcase for C for which my solution[submission:22243090] fail

»
3 years ago, # |
Rev. 3   Vote: I like it +23 Vote: I do not like it

I wrote a correct solution(I think it's a correct solution) for the problem E but when I was submitting it I choose the GNU C++ compiler instead of GNU C++11. Is it possible for the site administration to rejudge my submission with the right compiler?

link to my submission: http://codeforces.com/contest/734/submission/22248724

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

Suggestion:

Either 6 problems in 2.5 hours or 5 problems in 2 Hours.
Thank you!

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

For the beginning of the contest, I could not submit codes to problem A and C. The site kept me waiting without echoing anything, which really really annoys me (I have lost 100-200 points and spent some ten or twenty minutes trying to fix it). After each time I submitted a solution, I had to wait 1 or 2 minutes to see the result, and in most cases, it told me the connection was lost(maybe timeout?) and I must resubmit. Finally, I used a VPN proxy and it somehow worked. I think at the submit page there should be some js code to handle timeout, because (at least for me) a successful submission usually won't take a long time.

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

In problem E: Does the paint function simply work like the paint bucket in mspaint.exe (floodfill all adjacent nodes of the same color)? If yes, then the description is needlessly complicated. Interpreting it like this I used a disjoint set union, and tried to count the number of white and black sets and printed the minimum of them. Seems like I'm wrong...22248877

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

I'm really scared from C's tests everyone is failing in it.

:(

UPD: got it AC

:)

»
3 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

My B failed! :(
Can anyone tell me what is wrong in this?

ll k2,k3,k5,k6; cin>>k2>>k3>>k5>>k6;
ll mini=(k2,min(k5,k6));
ll sum=0; sum+=256LL*mini;
k2-=mini; k5-=mini; k6-=mini;
mini=min(k3,k2);
sum+=32LL*mini;
cout<<sum<<endl;

Edit:Jesus christ, I wrote (k2,min(k5,k6)) instead of min(k2,min(k5,k6)) ...... How does (k2,min(k5,k6)) get evaluated anyway?

TrueSadness.jpg :(

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

Solutions for C of many people failed any idea where it failed.

Upd: Mine too failed any idea on the mistake in my code

http://codeforces.com/contest/734/submission/22243843

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

    My solution failed i believe because i set maximum value for answer to be 10**16 (I thought n = 10**5)

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

    I got WA on test 13 because I forgot to take minimum of possible potion values and the original value of x, :/ Feels bad man. :/

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

    i think you forgot if pos <= 0 or something like that

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

      Thanks i got the mistake if upper bound return 0 pos becomes -1 .

      Facepalm :)

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

What's up with A? I understand it's Div. 2 A and you can give there pretty much anything solvable by anybody in less than 5 minutes (I have been an author myself), but I think it's too much: I feel like I have seen this problem ten times before, it's pretty much one loop and one if (no brain involved), and looks more like a programming language exercise.

Still thanks for a contest! :) I enjoyed E (and have no clue for F).

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

    True!!! :D Upd: i solved A in 1 min :D

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

    I remember Edvard saying problems A&B are harder to create than the rest, but yeah this is some next level ease.

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

    As you've seen C was a little bit hard, so I needed something very easy for A.

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

    I believe they meant to test the platform for a lot of quick submissions ;)

    I must say, well done, everything worked very smooth this round, good job!

    (I submitted A in second minute of the contest thinking how quick I am... and there were already 500 accepted submissions)

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

Auto comment: topic has been updated by alex256 (previous revision, new revision, compare).

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

Auto comment: topic has been updated by alex256 (previous revision, new revision, compare).

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

It was good

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

May be pretests will be more stronger!7! At least in realisations such as D

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

Where? ! :O

And also how Tutorial was available before the contest is over ! :P

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

In Problem D, It was stated that it's a x-y plane. However, it didn't seem like a Cartesian Coordinates System at all. :\

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

    It is a cartesian plane.

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

      X represented the row instead of the column, -ve rows(i.e -ve X) were on the top !

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

        That doesn't change the result. A rotated plane is still a plane.

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

anybody knows what is the bug on problem D ???

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

I am a new participant. After the contest my rating was not updated and my contest list doesn't show my participation in this round. Is there any problem with my profile or anything else?

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

Has anyone solved problem E,using dp on compressed tree ?

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

I had submitted a solution to the C problem during the contest and it was giving wrong answer on 5th pretest and I submitted the exact same solution after the contest and it is giving TLE on 6th pretest. I don't know why this is happening.

Submission during contest: http://codeforces.com/contest/734/submission/22240240

Submission after contest: http://codeforces.com/contest/734/submission/22250847

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

    Only

        #define xxx xx
    

    is added !!!

    Authority should take a look at this ! The both solution is same ! But for some reason during contest time there occurred a overflow ! for that output was -7166261092318506304 !! -_-

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

For problem C, can anybody please explain me why for input

10 3 3
10 33
1 7 6
17 25 68
2 9 10
78 89 125

output is 17 ?

Shouldn't the output be 10? Since Anton can use the 1st spell of the first type that costs 17 manapoints. Thus, the preparation time of each potion changes to 1 seconds. So the preparation time is 10*1 = 10.

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

Auto comment: topic has been updated by alex256 (previous revision, new revision, compare).

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

In problem C, I have used range minimum query segment tree + binary search to find the minimum possible time. I am getting WA on test 13. Testcase is pretty much large, cant figure it out manually, Somebody help please :) http://codeforces.com/contest/734/submission/22241998

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

    I had WA on the same test, make sure you're considering the case when you don't use any spells of the first type.

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

when will the ratings be updated!!!!!

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

I got a RUNTIME_ERROR on my submission 22244664 for problem D. If I run my solution locally, it runs fine. Does anyone have a clue?

--EDIT: Also on submission 22251648, which is the same code but cleaned up.

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

How long do they update the rating ?

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

We need more regular Rounds like this and in general more rounds..

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

A funny thing about the contest:

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

Waiting for the rating change..

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

i wonder if i will increase or decrease in rate ?

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

Can anyone say how many times needs to update with new rating? (I am new contestant).

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

Waiting.. waiting.. waiting... :(

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

i have an Exam tomorrow send me a message when you update the rate ,i am sleeping XD

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

    it's updated.

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

      YA thanks i got +40 . not bad i wish i get more next time , good luck for you too .

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

this was a great "prime in number" round :D

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

Deleted

»
3 years ago, # |
  Vote: I like it -43 Vote: I do not like it

Sooooo bad contest!

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

First time 'BLUE'! It's great to see my name in blue color! :D

»
3 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

alex256 Problem C: Can you check why test case 21 has only 3 lines, its hard to take input as in questions it specifies input in different lines.

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

    Codeforces doesn't show the tests fully, so you can see only 3 lines. But in fact there're 6 lines in the test.

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

This was my first competition and I really enjoyed solving the problems. Good job Alex! :)

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

That is a pity!I have read problem.E for more than one hour,but fail to understand the description until now,please illustrate your meaning clearly in the future.

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

Stuck on finding bug in submission 22242517 for 734C - Антон и зельеварение. Got error on 13 test case. Any suggestions, please?

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

    Consider the case where you meed to take only potion of the second type.

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

      May I ask you to provide some more details, please?

      I am iterating over all items of second type and searching for appropriate items of the first type using binary search in the for loop.

      For me it still looks like in 13 test case there is an item of second type with c == n and d <= s.

      for (long long i = 0; i < k; ++i) {
              if (snd[i].first > s) { break; }
              long long max_b = s - snd[i].first;
              long long r = n - snd[i].second;
              if (r <= 0) { min_time = 0; break; }
              long long a = min_fst(max_b, fst);
              if (a < 0) { a = x; } 
              min_time = std::min(min_time, r * a);
      }
      
      • »
        »
        »
        »
        3 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I'm a Java coder so I don't get what you've written, but I was in a similar situation as you are in now, after spending an entire day, I finally got AC, so I might be able to give you some insights : Consider all 3 cases: Let's say we have 'm' mana 1. when all potions of type 1 have mana requirement > m then binary search the highest value in second potion array 2. when all potions of type 2 have mana requirement > m then loop for every element in the first array and search for best value 3. When the answer is a combination of both

        One note in the binary search algorithm : consider the case when 2nd potion array is : 5 7 10 10 here cost of both is same but if we chose later one then the time is minimized, so in the binary search, remember to return the highest index of the key Take a look at my solution which is much readable

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

    Just figured out that min_fst function was incorrect. Should check if iterator points to the end after lower_bound if (it == fst.end()) { --it; }

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

I'm not sure whether I am right. I'm getting WA on test 1 in E. I checked the answer on my computer and it's 2. However, the result of the onlinejudge is 5, which makes me confused. I made the judge print the edges of the data1, it's 3 8 3 8 3 8 3 8 3 8 ???, and that made the wrong result. Also, I get RE on data1 if I chose C++11. I assume that the data of test1 is wrong? if not, why is the problem coursed? Thx

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

    Hi, I had a similar problem before. I see that you are using both scanf and ios::sync_with_stdio(0). Use either scanf or cin when u use ios::sync_with_stdio(0), but not both. That's the reason for the problem you are experiencing :) EDIT: Also, your code has wrong logic so correct that too :).

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

      Thank you! I solved this problem= = With regard to the wrong logic, I will think it over later = =

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

In problem C — -Anton and Making Potions, why do i have to insert certain values to each of a,b,c,d 's 0th index? I have read the problem statement again and again, just cannot understand why to put x at 'a's 0th index and et cetera. Could anyone pls explain why?

»
3 years ago, # |
Rev. 4   Vote: I like it -8 Vote: I do not like it

In problem E
Who can help me explain this example, why the answer is 3?
10
0 1 0 1 0 1 0 0 1 0
1 2
2 3
3 4
4 5
5 6
6 7
4 8
8 9
9 10

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

Solved all problems with Haskell. I really like your problems! :D :D :D