Блог пользователя gepardo

Автор gepardo, история, 7 лет назад, По-русски

Привет, Codeforces!

Завтра, 15 ноября 2016 в 19:35 (время московское) состоится очередной Codeforces раунд для участников из второго дивизиона. Как обычно, участники из первого дивизиона смогут поучаствовать вне конкурса.

Автор контеста — я (gepardo). Это мой первый раунд, и, надеюсь, не последний. Огромное спасибо Глебу Евстропову (GlebsHP) за помощь в подготовке контеста, Андрею Календарову (Andreikkaa) за тестирование раунда и Михаилу Мирзаянову (MikeMirzayanov) за великолепные платформы Codeforces и Polygon.

Как обычно, участникам будет предложено 6 задач и два часа на их решение. Рекомендую прочитать условия ВСЕХ задач. Желаю всем побольше Accepted'ов, и, конечно же, получить удовольствие от решения задач.

Задачи будут про моего младшего брата Антона. Надеюсь, они вам понравятся :)

Раунд рейтинговый.

UPD: Все-таки раунд будет не совсем обычный, и в нем будет 6 задач.

UPD2: А вот и разбалловка: 500-750-1250-1500-2000-2750.

UPD3: Разбор опубликован.

UPD4: Контест закончен, поздравляю победителей :)

Div. 2

  1. Octotentacle

  2. CisnijAsdPawel

  3. VemMonstro13

  4. fulvioabrahao

  5. Mehrdad_S

Div. 1

  1. sugim48

  2. uwi

  3. khadaev

  4. HellKitsune

  5. Um_nik

  • Проголосовать: нравится
  • +348
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Автокомментарий: текст был обновлен пользователем gepardo (предыдущая версия, новая версия, сравнить).

»
7 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Finally a 2 hour contest. Things are becoming usual now.

»
7 лет назад, # |
  Проголосовать: нравится +37 Проголосовать: не нравится

Finally a regular round!

»
7 лет назад, # |
  Проголосовать: нравится +49 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +131 Проголосовать: не нравится

Usual time? How unusual!

»
7 лет назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Here we go again :D

»
7 лет назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

It is becoming so usual to see comments about usuality

»
7 лет назад, # |
Rev. 4   Проголосовать: нравится -10 Проголосовать: не нравится

It is such a long time that has no contest!

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

is it rated?

»
7 лет назад, # |
  Проголосовать: нравится +20 Проголосовать: не нравится

Как необычно, раунд начнется в обычное время. Кстати когда там div1 раунд? А то жалко, давно уже не было, а люди ждут.

»
7 лет назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +82 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится

не могу участвовать из за времени! непривычное время!

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Я думаю, что не нужно проводить раунды каждый раз в одно время, так как в них участвуют спшники со всего мира. Нужно то днем, то ночью проводить, так как, когда у кого-то день, у кого-то другого ночь. На Удобное время право имеет каждый, с другой стороны каждый автор имеет также право провести свой раунд в удобное ему время. Думаю было бы классно, если авторы выбирались по очереди с разных краёв мира!

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Hope next contests will be a bit earlier.

»
7 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +17 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +23 Проголосовать: не нравится

    Thank you, it is me.

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится +2 Проголосовать: не нравится

      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

      • »
        »
        »
        »
        7 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится +22 Проголосовать: не нравится

        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!

»
7 лет назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Автокомментарий: текст был обновлен пользователем gepardo (предыдущая версия, новая версия, сравнить).

»
7 лет назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Автокомментарий: текст был обновлен пользователем gepardo (предыдущая версия, новая версия, сравнить).

»
7 лет назад, # |
  Проголосовать: нравится +24 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится -8 Проголосовать: не нравится

It seems that not having 5 problems is the new default

»
7 лет назад, # |
  Проголосовать: нравится -13 Проголосовать: не нравится

Щас бы длинку написать .

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

E test 3 — what was this?

»
7 лет назад, # |
  Проголосовать: нравится -22 Проголосовать: не нравится

Is this rated?

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

How to solve C?

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +11 Проголосовать: не нравится

    using binary search!!

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +9 Проголосовать: не нравится

    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

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

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

        • »
          »
          »
          »
          »
          7 лет назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          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 ?

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        What if we just need to cast spell type 2?

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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)

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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.

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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.

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    I solved it with two pointer technique

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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)

»
7 лет назад, # |
Rev. 102   Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится -13 Проголосовать: не нравится

What is the simpsons prediction about this contest ?

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +35 Проголосовать: не нравится

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

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

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

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      Why is the answer radius of the tree?

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится +24 Проголосовать: не нравится

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

      • »
        »
        »
        »
        7 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится +11 Проголосовать: не нравится

        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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Was E to Find largest number of alternating 0 and 1 in a chain then ans= (largest_chain/2) if largest_chain is even else largest_chain/2+1

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.

  • »
    »
    7 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    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

»
7 лет назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 3   Проголосовать: нравится +23 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

Suggestion:

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

»
7 лет назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится

Антон может использовать не более одного заклинания первого вида и не более одного заклинания второго вида, при этом суммарная стоимость заклинаний не должна превышать s единиц маны.

Заклинание не сгорает если его использовать. Может все таки стоило уточнить что и количество раз которое можно использовать ТО САМОЕ ЗАКЛИНАНИЕ не больше одного???? Решал весь контест другую задачу.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Извиняюсь за свою привычку не замечать основного и самого заметного)

Вопрос: когда будет проверка и начисление баллов (очков рейтинга)?

»
7 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

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.

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

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

:(

UPD: got it AC

:)

»
7 лет назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    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. :/

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +24 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +7 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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)

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

It was good

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

Where? ! :O

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится -9 Проголосовать: не нравится

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. :\

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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?

»
7 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

кайда рейтинг?! уйкым келип тур

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Автокомментарий: текст был обновлен пользователем gepardo (предыдущая версия, новая версия, сравнить).

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

when will the ratings be updated!!!!!

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

How long do they update the rating ?

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +37 Проголосовать: не нравится

A funny thing about the contest:

»
7 лет назад, # |
  Проголосовать: нравится +26 Проголосовать: не нравится

Waiting for the rating change..

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

dear codeforces PLEASEE UPDATE RATINGS ... maybe someone has to sleep and cant sleep : (

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Deleted

»
7 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Stuck on finding bug in submission 22242517 for 734C - Anton and Making Potions. Got error on 13 test case. Any suggestions, please?

  • »
    »
    7 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

    • »
      »
      »
      7 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      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);
      }
      
  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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; }

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

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

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

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

»
7 лет назад, # |
Rev. 4   Проголосовать: нравится -8 Проголосовать: не нравится

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

»
7 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

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