You are not logged in. Please login at www.codechef.com to post your questions!

×

collision problem- can i get help please ?

i have a problem, i need some explanation for how to fix it, can i get some help please ? full problem: https://drive.google.com/file/d/1yV5Es5CySy5u_mr1cEyoH6LdOLQjyP6E/view?usp=sharing

collision problem: there are n particles numbered from 0 to n-1 lined up from smallest to largest ID along the x-axis. the particles are all released simultaneously. once released, each particle travels indefinitely in a straight line along the positive x-axis at a speed. when two particles collide, the faster particle moves through the slower particles and they both continue moving without changing speed or direction. write a function that return the number of collision occurring with particle pos. collision has the following parameters: speed[speed[0] ... speed[n-1]]: an array of speed[i] indication speed of particle i. pos: index of the particle for which to count collisions. constraints * 1 <= n <= 100000 * 1 <= speed[i] <= 1000000000 * 0 <= pos< n

input: 8 6 1 6 3 4 6 8 2

output: 2

explanation: the particle at pos = 2 will collide with particle 0 and 1 as they pass it from behind.

asked 16 Dec '18, 04:08

elbehiry's gravatar image

0★elbehiry
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,738
×690
×1

question asked: 16 Dec '18, 04:08

question was seen: 61 times

last updated: 16 Dec '18, 04:08