tanishq2507's blog

By tanishq2507, history, 3 months ago, In English

there are n players. they have to collect m points.all the players and coins are in 1 D space ie on a number line.The initial location of all the players is given as the array players and locations of all points is given in points array.in one second a player can either move 1 step left or 1 step right or not move at all.A point is considered collected if any of the n players had visited the point;s location . the players can move simultaneously and independently of each other every second. the task is to find the minimum time in seconds required to collect all the points if players act optimally.

Example:

n=3, players = [3,6,7]

m = 4 points  = [2,4,7,9] Ans = 2 seconds.

my approach = binary search on time and check if it possible to reach all points in time t using two points by checking if absolute distance between the player and point is less than equal to max allowed by time t. but this gives false positive if the players is moving left and then has to come back to a point on its right in same time t.

how to solve this??

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By tanishq2507, history, 12 months ago, In English

https://codeforces.me/gym/104536/problem/F

The answer to this is max(d1,d2,ceil(d1/2)+ceil(d2/2)+1) where d1,d2 are diameters of the two trees.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By tanishq2507, history, 13 months ago, In English

Link to the problem...

I have tried this approach.Try to sort the subarray closer to the last index.Shift the window towards lefts if the new element in left is smaller than all the elements in the new window but this approach fails in one case.

Full text and comments »

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

By tanishq2507, history, 15 months ago, In English

This base conversion algorithm has an application in this problem 1811E - Living Sequence.Why does the base conversion work here.What do the remainders signify in the base conversion?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By tanishq2507, history, 15 months ago, In English

Maximum absolute sum of a subarray =Max prefix sum — Min prefix sum(prefix sum includes zero).

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By tanishq2507, history, 17 months ago, In English

I had got this question in Cisco coding round. I would be grateful if anyone could provide an approach or even an hint. Problem statement is quite long ,please bear with me.

Mr McFly has gone k number of Days into the past. He knows the prices of stocks in the stock market and how much profit they are going to generate if invested. In order to generate profit on investing in a stock ,McFly has to wait for one day to generate the profit and subsequently invest in other stock. Also his broker only allows investing in 1 stock per day and holding period is 1 day per stock. To keep things simple, if Marty invests in a stock ,he won't be able to reinvest in that stock.

McFly has an array of price of n stocks ,where price[i] denotes the price of ith stock and an array of profit of size n where profit[i] denotes the profit generated after a day of investing in the ith stock. McFly has an initial funds f and he can use the profit from stocks to invest in other stocks.Help McFly in picking at most k stocks for k days so as to maximize his funds. Any stock can be picked at any time .

Given k days into the past,initial funds f,price array and profit array print the maximum funds at the end if at most k number of stocks are picked for investment intelligently.

Constraints: 1 <= k <= 10^5 0 <= f <= 10^7

Full text and comments »

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