Problem title
Difficulty
Avg time to solve

Word Pattern
Easy
15 mins
Make Palindrome
Easy
--
Gas Stations
Moderate
10 mins
Number of GP sequence
Moderate
10 mins
Perfect Number
Easy
10 mins
Form the Biggest Number
Moderate
25 mins
Check Square
Moderate
10 mins
Longest Increasing Subsequence
Moderate
--
Sorted Subsequence of Size 3
Moderate
15 mins
Remove maximum edges
Easy
15 mins
2

Water Droplet Mixing

Difficulty: EASY
Contributed By
Anish De |Level 1
Avg. time to solve
28 min

Problem Statement

Consider a pipe of length L. The pipe has N water droplets at N different positions within it. Each water droplet is moving towards the end of the pipe (x = L) at different speeds. When a water droplet mixes with another water droplet, it assumes the speed of the water droplet it is mixing with, or to put it in other words, the water resulting water droplet formed post mixing will take the speed of the smaller ones.

Determine the number of droplets that come out of the pipe.

Input format :
The first line contains an integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow.

The first line of each test case or query contains two integers(N and L) separated by a single space. Where 'N' represents the number of water droplets present in the pipe initially and 'L' represents the length of the pipe.

The second line contains 'N' single space-separated integers representing the positions of the droplets initially.

The third line contains 'N' single space-separated integers representing the velocities of the droplets initially.
Output Format :
For each test case, return the number of water droplets that come out of the pipe.

Output for every test case will be printed in a separate line.
Note:
The positions of all the droplets are unique in that is no water droplet will have the same initial position.

You do not need to print anything, it has already been taken care of.
Constraints :
1 <= t <= 100
0 <= N <= 10^5
1 <= L <= 10^9
0 <= Position[i] <= L
1 <= Speed[i] <= 10^9

Time Limit: 1 sec
Sample Input 1 :
1
5 12
10 8 0 5 3
2 4 1 1 3
Sample Output 1 :
3
Sample Input 2 :
1
2 5
0 1
1 1
Sample Output 2 :
2
Reset Code
Full screen
copy-code
Console