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

Автор LemonMonster, история, 4 года назад, По-английски

Hello Everybody , Recently I was learning Binary Search and tried to to solve thsi problem using it. -- Link to the problem. My solution is like the one given in step 2 of binary search in codeforces edu by pashka
I have a good function to check if the people are enough to reach the desired place. in the beginning the l is 0 and the r is 1. then I continue multiplying r by 2 unless i reach a solution (r is definitely true ) then I binary search for the answer. But my program gives time limit exceeded.

My full solution



Only the good function



The mian function



Полный текст и комментарии »

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

Автор LemonMonster, 4 года назад, По-английски

Spoilers are broken! Sorry for the inconvenience!

Introduction

The contest can be found here
This is an unofficial editorial and I am no way associated to Vplanet!
. Also this is my second ever blog on first code forces , and I have tried to replicate many editorial blogs as far as possible, but if I have made any mistake , please do let me know :D

Problem A Arya and Bran

We notice that the maximum amount of candies that we can give is 8 the rest of the candies are carry forward to the next day
So more formally , the tofees given on day i is min(arr[i],8)
and the number of candies carry forward are max(0,arr[i]-8).

Solution

____________________________________________________________________________________

Problem B Love Triangle

For this problem we can directly check that there is a triangle formed , by the numbers written on the array and then print the answer accordingly

Solution

____________________________________________________________________________________

Problem C — Chess for three

So for this problme we need to know the following details , the person who is watching , and the players who are playing , if the winner is the spectator at any point of time then the game is not possible or else its possible.

Solution

____________________________________________________________________________________

D. Fafa and his Company

We can run a loop from the 1 to the number given and check if (number-i)%i == 0 as it is the only way that all the leaders have same number of people working under them.

Solution

____________________________________________________________________________________

E. Restaurant Tables

In this problem we can take in input and check if the person is 2 seater or one seater , then if a person is two seater then we check if we have a two seater left , else we disappoint 2 customers. If its a one seater and we donot have a 1 seater left but we have a 2 seater left ,then we can put the one person there are increase the count of one seater as now anathor one person can sit with him

Solution

____________________________________________________________________________________

F. Between the Offices

We can see the number of times the person moves from S to F and from F to S and then depending depending on the cound check if we have to print no or yes

Solution

Полный текст и комментарии »

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

Автор LemonMonster, история, 4 года назад, По-английски

Introduction

The contest can be found here
This is an unofficial editorial and I am no way associated to Vplanet!
. Also this is my first day at code forces and my first ever blog on first code forces , and I have tried to replicate many editorial blogs as far as possible, but if I have made any mistake , please do let me know :D

Problem A Key Races

So How do we calculate the time taken by a person. The person takes v seconds to type a character. And he is supposed to type s characters. He also faces a lag of t seconds 2 times , In the beginning while loading and second time when the site gets his data. So the formula to calculate the time would be:
Time = (v*s)+(2*t)
So now we can calculate the time by both participants and compare thus printing the output accordingly

Solution

____________________________________________________________________________________

Problem B — Fafa and the Gates

Lets plot the x=y graph and check how it looks like

Now we will notice that the person will be in the first kingdom if the x cordinate is greater than the y cordinate and is in the second kingdom when x cordinate is greater than y. So you can make a vector of at a time where the person is ie. kingdom 1 or kingdom 2. Tehn you can check the number of times he changes from one to two or vice versa.

Solution

____________________________________________________________________________________

Problem C — Bark to Unlock

So the dog will obviously unlock if he speaks that exact same word, so that can be a preliminary test. Also we notice that the password has only letters . So we can traverse through the words the enemy can speak and check if the first letter of the password is the last letter of one of the word the enemy can speak and if the last letter of the password is the first letter of one of the word , so he can speak these words simultaneously and pronounce the word. Also as we notice in the third testcase how speaking the word reverse it . So check if the enemy can speak the reverse word as well.

Solution

____________________________________________________________________________________

D. Race Against Time

In this problem fuirst we need to mark all the positoon of the hands. then from the current time we can either go back or front , If in this process we meet any hand , then we cannot use that method. So if either up is possible or down is possible , print Yes or print No

Solution

Полный текст и комментарии »

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