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

Автор tanishq2507, история, 3 месяца назад, По-английски

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??

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

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

Автор tanishq2507, история, 12 месяцев назад, По-английски

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.

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

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

Автор tanishq2507, история, 13 месяцев назад, По-английски

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.

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

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

Автор tanishq2507, история, 14 месяцев назад, По-английски

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?

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

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

Автор tanishq2507, история, 14 месяцев назад, По-английски

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

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

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

Автор tanishq2507, история, 16 месяцев назад, По-английски

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

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

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