0% found this document useful (0 votes)
5 views2 pages

Moo (En)

The document presents a problem from the Bangladesh Olympiad in Informatics involving the fair distribution of biscuits among chickens based on their weights. Given 'n' chickens and 'm' biscuits, the goal is to determine the maximum number of biscuits that can be distributed while maintaining proportionality to each chicken's weight. The input format specifies the number of chickens, total biscuits, and their respective weights, with constraints on their values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Moo (En)

The document presents a problem from the Bangladesh Olympiad in Informatics involving the fair distribution of biscuits among chickens based on their weights. Given 'n' chickens and 'm' biscuits, the goal is to determine the maximum number of biscuits that can be distributed while maintaining proportionality to each chicken's weight. The input format specifies the number of chickens, total biscuits, and their respective weights, with constraints on their values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Bangladesh Olympiad in Informatics moo

Preliminary Round Preliminary T asks


4 February, 2023 English

Moo
After mastering every algorithm in existence, you have decided to look for new things to do. You have
heard about Mr. Pepe, who hasn’t got bored even after mastering every algorithm. He now runs a
large poultry farm, which has n chickens. The weight of i-th chicken is w[i].

To make a friendship with Mr. Pepe, you want to distribute the biscuits among the chickens. However,
you are an artist (as is every programmer), so you want to distribute the biscuits in a fair manner. The
number of biscuits received by a chicken should be proportional to its weight. Formally, Let f [i] be
the number of biscuits received by the i-th chicken. Then the following condition must be satisfied:

f [i] w[i]
= , for every 1 ≤ i, j ≤ n
f [j] w[j]
​ ​

You have m biscuits. What is the maximum number of biscuits you can distribute satisfying the above
condition?

Input
Read the input from the standard input in the following format:

line 1 : n m
line 2 : w[1] w[2] … w[n]

Output
Write the output to the standard output in the following format:

line 1 : The maximum number of biscuits you can distribute.

Constraints
1 ≤ n ≤ 200 000
1 ≤ m ≤ 10 15
1 ≤ w[i] ≤ 10 9 (for all 1 ≤ i ≤ n)

Subtasks
1. (2 points) n = 1
2. (4 points) m = 1

moo (1 of 2)
3. (19 points) n = 2
4. (10 points) n ≤ 100 , w[i] ≤ 100 , m ≤ 10 5
5. (15 points) w[i] = w[j] (for all 1 ≤ i, j ≤ n)
6. (20 points) There is at least one i such that w[i] = 1 .
7. (30 points) No further constraints.

Examples

Example 1

3 12
1 1 3‎

The correct output is:

10‎

The number of biscuits distributed should be 2 , 2 , 6 respectively.

Example 2

5 10
1 5 2 3 1‎

The correct output is:

0‎

Here, you cannot distribute any number of biscuits in a fair manner. Thus the answer is 0 .

Example 3

1 5
7‎

The correct output is:

5‎

Here you have 5 biscuits and 1 chicken. You should give all your biscuits to the single chicken.

moo (2 of 2)

You might also like