Neeraj_Kumar_Coder's blog

By Neeraj_Kumar_Coder, history, 15 months ago, In English

You are given two arrays A (size m) and B (size n). You have to choose some elements from A and B such that the resulting array (size d) is lexicographically maximum. The only constraint here is that you have to maintain the relative ordering of the elements taken from the same array.

Example 1

Input

4 6 5

2 3 5 4

8 0 1 4 7 2

Output

8 7 5 4 2

Example 2

Input

2 3 5

7 8

7 1 5

Output

7 8 7 1 5

Constraints:

1 < m, n ≤ 512

1 < d ≤ (m + n)

0 ≤ A[i], B[j] ≤ 9

Full text and comments »

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

By Neeraj_Kumar_Coder, history, 2 years ago, In English

Statement

It's the world tourism day and agoda has launched a special promocode with each hotel booking a person makes, they can get a cashback randomly and uniformly distributed from the range [1, maxCashback] in integer USD. A person will start with 0 cashback and can keep applying this promocode until they secure a minimum of M USD in total across all his future bookings.
To keep the customers happy, Agoda wants to ensure that majority of people can make atleast H USD from this promocode.
Find the probability of a customer being not happy (total cashback < H) with this promocode. Given M, maxCashback, H.

Constraints

0 <= M <= H <= 1e4
1 <= maxCashback <= 1e4

Output

The calculated probability

SAMPLE TEST CASE

1 10 6

OUTPUT

0.50000

Full text and comments »

By Neeraj_Kumar_Coder, history, 2 years ago, In English

Statement

You are given an array consisting of only 0, 1 and 2. Also given two integers x and y. Your task is to find the number of subarrays with ratio of frequency of 0 and 1 being x : y.

Input

The first line of input contains and integer n, denoting the number of elements in the array.
The next line contains n space separated integers denoting elements of array.
The next line contains two integers x and y.

Output

Output the number of subarrays having 0's and 1's in the ratio x : y.

CONSTRAINTS

2 <= n <= 1e5
1 <= x, y <= n

SAMPLE TEST CASE

5
0 1 2 0 1
1 1

OUTPUT

6

Full text and comments »