2 views

Uploaded by ashishtrivediscr

- Problem 8
- Problem 7
- Problem 6
- Problem 4
- Problem 3
- Problem 2
- Bitwise Solutions 2010
- Problem 1: Help the Tree of Souls
- ASPHand Book
- The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
- Sapiens: A Brief History of Humankind
- Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
- Shoe Dog: A Memoir by the Creator of Nike
- The Library Book
- The Unwinding: An Inner History of the New America
- Never Split the Difference: Negotiating As If Your Life Depended On It
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- Yes Please
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- Grit: The Power of Passion and Perseverance

You are on page 1of 2

(100 points)

It’s time for the final battle and the Na’vi are preparing an army. After a

thorough inspection of the soldiers, Tsu’tey has given each soldier a value which

accounts for qualities like his strength, skills in battle, leadership skills etc.

However, thanks to the battleplan of the Na’vi, the soldiers have to be placed

in a particular order. Any deviation from this order would lead to total disaster.

The soldiers are divided into platoons. Platoons move in a straight line one after

the another. The total strength of a platoon is equal to the sum of the strengths

of the individual soldiers constituting the platoon. During the arrangement, if

a platoon X with higher strength than platoon Y is placed behind platoon

Y, then this is a mismatch. Tsu’tey and Jake Sully wish to keep track of the

number of such mismatches. Too many mismatches would lead to weakening of

the battle formation and eventual defeat. Since the number of mismatches is

dependent on the platoon strength, Jake and Tsu’sey wish to try out various

platoon sizes (their math is really weak, so all they can do is trial and error).

They have asked you to help them out. They will divide the army into platoons,

compute the strength of each platoon and ask you to find how many arrange-

ments of the platoons in a straight line would give atmost a certain number of

mismatches. Can you help them out? You may assume that no two platoons

have same strength.

Input format:

For each test case:

a. The first line contains an integer N giving the number of platoons and an

integer k giving the maximum number of mismatches.

b. The next N lines have one integer per line, signifying the strength of the N

platoons.

Output format:

For each test case, output one integer (modulo 1000) giving the number of

arrangements of the platoons in a straight line such that there are atmost k

mismatches.

1

Sample Input:

1

95

95

34

12

65

13

78

22

54

82

Sample Output:

785

- Problem 8Uploaded byashishtrivediscr
- Problem 7Uploaded byashishtrivediscr
- Problem 6Uploaded byashishtrivediscr
- Problem 4Uploaded byashishtrivediscr
- Problem 3Uploaded byashishtrivediscr
- Problem 2Uploaded byashishtrivediscr
- Bitwise Solutions 2010Uploaded byashishtrivediscr
- Problem 1: Help the Tree of SoulsUploaded byashishtrivediscr
- ASPHand BookUploaded byarchana_chary16