7 posts
• Page **1** of **1**

This is a very easy problem. Most probably this was the easiest problem in the contest and got most solve.

This problem is based on a basic physics equation from high school physics. Formula for deceleration can be easily found in internet or in physics book. The only tricky part is the final velocity of the car will be zero as the problem statement says, the car will completely halt. If you know the formula and if you are able to process input/output, then there is nothing else that will stop you from solving it.

In this problem if you observe all the term you will get a relation between them. There is actually 4 term given in the problem 3 is in the main question and one is in the sample input/output. So it is actually pretty much easy to find the sequence after observing those four term.

**Posts:**3**Joined:**Wed Nov 16, 2016 9:59 am

If you have already solved some problems based on dynamic programming, you should not find it hard to solve this problem.

Can you write a recursive function to check if a sub-string of a string is palindrome or not? I hope you can. My solution is very similar to a recursive palindrome checker. What do you do in a palindrome checker? If you find a match in both sides of your sub-string S[l, r] you can reduce your problem to S[l + 1, r - 1]. Otherwise, you can say that the sub-string is not palindrome.

Now, you are not asked to answer if the given string is palindrome or not.

Let's define dp[l][r] as the minimum number of characters to add to make the sub-string S[l, r] a palindrome. Now you can solve your problem with two simple transactions.

1. If S[l] and S[r] are equal, you can not get a better solution than considering S[l] and S[r] as reflexive characters of your new palindromic string, as you are not having any cost of adding a new character.

Example, Result("ahbfhba") = Result("hbfhb");

So, dp[l][r] = dp[l + 1][r - 1], if S[l] = S[r].

2. If S[l] and S[r] are not equal, then you have no other option than adding an extra character in one of the sides to have a match. Let say, your current string is dfghdc. If you want to have a match in both sides, you can make it dfghdcd or cdfghdc.

Result("dfghdc") = 1 + Minimum ( Result("fghdc"), Result("dfghd") ).

So, dp[l][r] = 1 + Minimum (dp[l + 1][r], dp[l][r - 1]), if S[l] != S[r].

In this problem there will be given N the number of student. In the next N line there will be two input one string and one floating point number.

Now for storing those number we can use structure consist of string and double. Like :

struct myStruct{

string name;

double cgpa;

};

Now we have to sort those data according to the question. But be careful about the merit position in the time of printing the output as two or more person can have same merit position.

**Posts:**3**Joined:**Wed Nov 16, 2016 9:59 am

Ive used that idea too, but I think people get lost in it when theres no visual.

Pressure = brightness seems harder to get than depth = brightness...as they can visualize depth and not pressure.

I wanted to explain lumens vs lux more than how to get throw vs flood per se...with an easy way to visualize what each is about.

Pressure = brightness seems harder to get than depth = brightness...as they can visualize depth and not pressure.

I wanted to explain lumens vs lux more than how to get throw vs flood per se...with an easy way to visualize what each is about.

**Posts:**2**Joined:**Thu Jun 15, 2017 12:35 am**Location:**Broornnerne

**Posts:**2**Joined:**Thu Jun 15, 2017 12:35 am**Location:**Broornnerne

7 posts
• Page **1** of **1**

Who is online

Users browsing this forum: No registered users and 0 guests